First class MyLed with member initializer lists
Revision 0:6a370b8037bf, committed 2020-10-06
- Comitter:
- bulmecisco
- Date:
- Tue Oct 06 15:32:23 2020 +0000
- Commit message:
- First program with member initializer lists
Changed in this revision
MyLed.cpp | Show annotated file Show diff for this revision Revisions of this file |
MyLed.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyLed.cpp Tue Oct 06 15:32:23 2020 +0000 @@ -0,0 +1,15 @@ +#include "mbed.h" +#include "MyLed.h" + +// Methoden oder Memberfunktions +void MyLed::ledOn() { + _led = 1; +} + +void MyLed::ledOff() { + _led = _wert; +} + +void MyLed::printStatus() { + printf("Led is now: %d\n", _led.read()); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyLed.h Tue Oct 06 15:32:23 2020 +0000 @@ -0,0 +1,20 @@ +#include "mbed.h" +#ifndef MYLED_H +#define MYLED_H + +// Klasse +class MyLed{ +private: + // Memebervariable + DigitalOut _led; + const int _wert; +public: + // Konstruktor + MyLed(PinName led) : _led(led), _wert(0) { + } + // Methodenprototyping + void ledOn(); + void ledOff(); + void printStatus(); +}; +#endif \ No newline at end of file