Andreas Brunnhofer
/
init_1
Initialisierungslisten Uebung 1
init_1.cpp@1:5f898b1088f7, 2020-10-06 (annotated)
- Committer:
- Mr_Anderssson
- Date:
- Tue Oct 06 17:24:53 2020 +0000
- Revision:
- 1:5f898b1088f7
- Parent:
- main.cpp@0:6caf95389cc7
- Child:
- 2:32751b274adb
Uebung 3
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mr_Anderssson | 1:5f898b1088f7 | 1 | |
Mr_Anderssson | 0:6caf95389cc7 | 2 | //Initialisieren Sie in der folgenden Klasse mittel Initialisierungsliste |
Mr_Anderssson | 0:6caf95389cc7 | 3 | //den _messwert mit 0: |
Mr_Anderssson | 0:6caf95389cc7 | 4 | |
Mr_Anderssson | 0:6caf95389cc7 | 5 | #include "mbed.h" |
Mr_Anderssson | 0:6caf95389cc7 | 6 | |
Mr_Anderssson | 0:6caf95389cc7 | 7 | class MyClass |
Mr_Anderssson | 0:6caf95389cc7 | 8 | { |
Mr_Anderssson | 0:6caf95389cc7 | 9 | public: |
Mr_Anderssson | 0:6caf95389cc7 | 10 | MyClass(double messwert) : _messwert(messwert) { } |
Mr_Anderssson | 0:6caf95389cc7 | 11 | MyClass( ) : _messwert(0.0) { } |
Mr_Anderssson | 0:6caf95389cc7 | 12 | |
Mr_Anderssson | 0:6caf95389cc7 | 13 | void status() |
Mr_Anderssson | 0:6caf95389cc7 | 14 | { |
Mr_Anderssson | 0:6caf95389cc7 | 15 | printf("%f\n", _messwert); |
Mr_Anderssson | 0:6caf95389cc7 | 16 | } |
Mr_Anderssson | 0:6caf95389cc7 | 17 | private: |
Mr_Anderssson | 0:6caf95389cc7 | 18 | double _messwert; |
Mr_Anderssson | 0:6caf95389cc7 | 19 | }; |
Mr_Anderssson | 0:6caf95389cc7 | 20 | |
Mr_Anderssson | 0:6caf95389cc7 | 21 | MyClass myClass(0.0); |
Mr_Anderssson | 0:6caf95389cc7 | 22 | |
Mr_Anderssson | 0:6caf95389cc7 | 23 | int main() |
Mr_Anderssson | 0:6caf95389cc7 | 24 | { |
Mr_Anderssson | 0:6caf95389cc7 | 25 | myClass.status(); |
Mr_Anderssson | 0:6caf95389cc7 | 26 | wait_ms(100); |
Mr_Anderssson | 0:6caf95389cc7 | 27 | } |
Mr_Anderssson | 0:6caf95389cc7 | 28 |