Duric_Initialisierungsliste Übung1

Files at this revision

API Documentation at this revision

Comitter:
sandrodjuric
Date:
Tue Oct 13 17:19:36 2020 +0000
Parent:
2:9e69637ca6ca
Commit message:
kj

Changed in this revision

UberladenvonKonstruktor2.cpp Show annotated file Show diff for this revision Revisions of this file
Ubung3.cpp Show diff for this revision Revisions of this file
uberladen_konst.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 9e69637ca6ca -r 6b2ff327d68a UberladenvonKonstruktor2.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/UberladenvonKonstruktor2.cpp	Tue Oct 13 17:19:36 2020 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+
+class MyClassA {
+    private:    
+    int _x;
+    bool _wahr;
+public:
+   
+    int getx(void) 
+    {
+        return _x;
+        
+    }
+    bool getwahr(void)
+    {
+        return _wahr;
+    }
+    MyClassA(int x, bool wahr) {
+        _x = x;
+        _wahr = wahr;
+    }
+     void printWert(){
+         printf("_x : %d  _wahr: %d \n", _x, _wahr);
+         
+     }
+    void printWert(int &neuwert){
+        neuwert = 10;
+        printf("_x : %d neuwert: %d  _wahr : %d \n", _x, neuwert, _wahr);
+        
+    }
+};
+
+ MyClassA myclassa (0,0) ;
+ MyClassA myclassa2 (5,1) ;
+int main()
+{
+   
+    int wert;
+    myclassa.printWert();
+    myclassa2.printWert();
+    myclassa2.printWert(wert);
+    printf("%d\n", myclassa.getx());
+    printf("%d\n", myclassa.getwahr());
+}
diff -r 9e69637ca6ca -r 6b2ff327d68a Ubung3.cpp
--- a/Ubung3.cpp	Tue Oct 06 17:18:08 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-#include "mbed.h"
-#include "platform/mbed_thread.h"
-
-class MyClassB {
-public:
-  MyClassB(PinName sda, PinName scl): _i2c(sda,scl){
-      _result=0;
-      }  
-  float read(); 
-  
-private:
-  I2C i2c;
-  float _result;
-};
-float MyClassB::read(){
- return _result;
- }
- 
- 
-MyClassB myclassb(0.0);
-MyClassB sensor(p28, p27);
-
-int main(){
-    myclassb.status();
-    printf("%f\n",sensor.read());
-    }
diff -r 9e69637ca6ca -r 6b2ff327d68a uberladen_konst.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uberladen_konst.cpp	Tue Oct 13 17:19:36 2020 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+
+class MyClass{
+public:
+    MyClass() : _messwert(0) {
+        _messwert = 1;         
+    }
+    MyClass(double messwert) : _messwert(messwert){
+        
+    }
+    void printWert(){
+        printf("messwert: %f\n", _messwert);
+    }
+    void printWert(int izahl){
+        printf("messwert: %f izahl: %d\n", _messwert, izahl);
+    }
+    void printWert(int izahl, int &anz){
+        anz = 20;
+        printf("messwert: %f izahl: %d anzParam: %d\n", _messwert, izahl,anz);
+    }
+    private:
+    double _messwert;
+};
+
+MyClass m;
+MyClass m2(5);
+
+int main(){
+    int anzahl = 0;
+    while(1){
+        m.printWert();
+        wait(1);
+        m2.printWert();
+        wait(1);
+         m2.printWert(144);
+        wait(1);
+         m2.printWert(144, anzahl);
+        wait(1);
+         m2.printWert(1);
+        wait(1);
+        
+    }
+}
\ No newline at end of file