Florian Rasser
/
Rasser_TINF_2020_10_06_Initialisierungslisten_2
Init Liste messwert mit 0 initialisieren + MyClassA int & bool
Revision 1:c32673cb0c2f, committed 2020-10-06
- Comitter:
- floras
- Date:
- Tue Oct 06 15:56:36 2020 +0000
- Parent:
- 0:6a84376bbf45
- Commit message:
- Init Liste Bsp 2: MyClassA
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 06 15:30:37 2020 +0000 +++ b/main.cpp Tue Oct 06 15:56:36 2020 +0000 @@ -1,29 +1,47 @@ #include "mbed.h" - - -class MyClass{ +class MyClass +{ public: - MyClass(double messwert) : _messwert(messwert) { + MyClass(double messwert) : _messwert(messwert) + { } - -void status() { - printf("%f\n", _messwert); - -} + + void status() + { + printf("%f\n", _messwert); + } private: double _messwert; }; +class MyClassA +{ +public: + MyClassA(int x, bool wahr) : _x(x), _wahr(wahr) {} + int getx(void) + { + return _x; + } + bool getwahr(void) + { + return _wahr; + } +private: + int _x; + bool _wahr; +}; MyClass myClass (0); +MyClassA myClassA (6, 0); -int main() { - - myClass.status(); - wait_ms(100); - - } +int main() +{ + myClass.status(); + printf("%d\n", myClassA.getx()); + printf("%d\n", myClassA.getwahr()); + wait_ms(100); +}