Robin Handy
/
Initialisierungslisten
1 Uebung
Diff: main.cpp
- Revision:
- 4:6bea8ed92ad7
- Parent:
- 3:dbd662e5f8f8
- Child:
- 5:a0a51cfb3981
--- a/main.cpp Tue Oct 06 16:13:34 2020 +0000 +++ b/main.cpp Tue Oct 06 16:17:45 2020 +0000 @@ -1,33 +1,31 @@ #include "mbed.h" +class MyClass +{ +public: + MyClass(double messwert) : _messwert(messwert) //Initialisierungsliste + { + } + + void status() //Funktion die den status von Messwert abfragt + { + printf("%f\n", _messwert); + + } + +private: + double _messwert; +}; -class MyClassA{ -public: - MyClassA(int x, bool wahr) : _x(x), _wahr(wahr) {} - -void printstatus(){ - printf("x ist: %d\n", _x); - printf("bool ist: %d\n", _wahr); - -} - int getx(void) {return _x;} -private: - int _x; - bool _wahr; - -}; - -MyClassA myclassA(5,1); - +MyClass myclass(0); int main() -{while(1){ - - myclassA.printstatus(); - - wait_ms(500); - -} +{ + while(1) { + + myclass.status(); + wait_ms(500); + } }