Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@1:c32673cb0c2f, 2020-10-06 (annotated)
- Committer:
- floras
- Date:
- Tue Oct 06 15:56:36 2020 +0000
- Revision:
- 1:c32673cb0c2f
- Parent:
- 0:6a84376bbf45
Init Liste Bsp 2: MyClassA
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| floras | 0:6a84376bbf45 | 1 | #include "mbed.h" | 
| floras | 0:6a84376bbf45 | 2 | |
| floras | 1:c32673cb0c2f | 3 | class MyClass | 
| floras | 1:c32673cb0c2f | 4 | { | 
| floras | 0:6a84376bbf45 | 5 | public: | 
| floras | 1:c32673cb0c2f | 6 | MyClass(double messwert) : _messwert(messwert) | 
| floras | 1:c32673cb0c2f | 7 | { | 
| floras | 0:6a84376bbf45 | 8 | } | 
| floras | 1:c32673cb0c2f | 9 | |
| floras | 1:c32673cb0c2f | 10 | void status() | 
| floras | 1:c32673cb0c2f | 11 | { | 
| floras | 1:c32673cb0c2f | 12 | printf("%f\n", _messwert); | 
| floras | 1:c32673cb0c2f | 13 | } | 
| floras | 0:6a84376bbf45 | 14 | |
| floras | 0:6a84376bbf45 | 15 | private: | 
| floras | 0:6a84376bbf45 | 16 | double _messwert; | 
| floras | 0:6a84376bbf45 | 17 | }; | 
| floras | 0:6a84376bbf45 | 18 | |
| floras | 1:c32673cb0c2f | 19 | class MyClassA | 
| floras | 1:c32673cb0c2f | 20 | { | 
| floras | 1:c32673cb0c2f | 21 | public: | 
| floras | 1:c32673cb0c2f | 22 | MyClassA(int x, bool wahr) : _x(x), _wahr(wahr) {} | 
| floras | 1:c32673cb0c2f | 23 | int getx(void) | 
| floras | 1:c32673cb0c2f | 24 | { | 
| floras | 1:c32673cb0c2f | 25 | return _x; | 
| floras | 1:c32673cb0c2f | 26 | } | 
| floras | 0:6a84376bbf45 | 27 | |
| floras | 1:c32673cb0c2f | 28 | bool getwahr(void) | 
| floras | 1:c32673cb0c2f | 29 | { | 
| floras | 1:c32673cb0c2f | 30 | return _wahr; | 
| floras | 1:c32673cb0c2f | 31 | } | 
| floras | 1:c32673cb0c2f | 32 | private: | 
| floras | 1:c32673cb0c2f | 33 | int _x; | 
| floras | 1:c32673cb0c2f | 34 | bool _wahr; | 
| floras | 1:c32673cb0c2f | 35 | }; | 
| floras | 0:6a84376bbf45 | 36 | |
| floras | 0:6a84376bbf45 | 37 | MyClass myClass (0); | 
| floras | 1:c32673cb0c2f | 38 | MyClassA myClassA (6, 0); | 
| floras | 0:6a84376bbf45 | 39 | |
| floras | 1:c32673cb0c2f | 40 | int main() | 
| floras | 1:c32673cb0c2f | 41 | { | 
| floras | 1:c32673cb0c2f | 42 | myClass.status(); | 
| floras | 1:c32673cb0c2f | 43 | printf("%d\n", myClassA.getx()); | 
| floras | 1:c32673cb0c2f | 44 | printf("%d\n", myClassA.getwahr()); | 
| floras | 1:c32673cb0c2f | 45 | wait_ms(100); | 
| floras | 1:c32673cb0c2f | 46 | } | 
| floras | 0:6a84376bbf45 | 47 |