Vererbung mit HasA und IsA.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
franzpaulus
Date:
Tue Nov 27 16:18:11 2018 +0000
Commit message:
Vererbung mit HasA und IsA.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 812a994ef5c6 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 27 16:18:11 2018 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+
+class IsA : public DigitalOut {
+    public:
+    IsA(PinName ld) : DigitalOut(ld){};   //Konstruktor
+};
+
+class HasA {
+    public:
+    HasA(PinName ld) : _led(ld) {};        //Konstruktor
+    void schreibe(int x){
+        _led.write(x);
+    }
+    private:
+    DigitalOut _led;
+};
+
+DigitalOut myled1(LED1);
+IsA myled2(LED2);
+HasA myled3(LED3);
+
+DigitalIn sw1(p22);
+DigitalIn sw2(p23);
+DigitalIn sw3(p14);
+
+int main() {
+    while(1) {
+        myled1 = !sw1;
+        myled2.write(!sw2);
+        myled3.schreibe(!sw3);
+    }
+}
diff -r 000000000000 -r 812a994ef5c6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 27 16:18:11 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file