Michael Planner
/
InitListen
Codeschnippseln für diese Übung
class3.cpp@1:c65875995efb, 2020-10-13 (annotated)
- Committer:
- Aagrus
- Date:
- Tue Oct 13 16:34:21 2020 +0000
- Revision:
- 1:c65875995efb
- Parent:
- 0:76d9c940a794
UPDATE: Hinzugefuegt -> Ueberladener Konstruktor
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Aagrus | 0:76d9c940a794 | 1 | class MyClassC |
Aagrus | 0:76d9c940a794 | 2 | { |
Aagrus | 0:76d9c940a794 | 3 | private: |
Aagrus | 1:c65875995efb | 4 | const int _a; // Zuweisung von Konstanten und Referenzen ist nur in der |
Aagrus | 1:c65875995efb | 5 | int& _b; // Initialisierungsliste, nicht im Konstruktorrumpf zulässig. |
Aagrus | 1:c65875995efb | 6 | int _c; |
Aagrus | 1:c65875995efb | 7 | int _d; |
Aagrus | 0:76d9c940a794 | 8 | |
Aagrus | 0:76d9c940a794 | 9 | public: |
Aagrus | 1:c65875995efb | 10 | MyClassC(int& refB) : _b(refB), _a(2) |
Aagrus | 1:c65875995efb | 11 | { |
Aagrus | 1:c65875995efb | 12 | _c = 0; |
Aagrus | 1:c65875995efb | 13 | _d = 0; |
Aagrus | 1:c65875995efb | 14 | } |
Aagrus | 1:c65875995efb | 15 | MyClassC(int& refB, int const a) : _b(refB), _a(a) |
Aagrus | 0:76d9c940a794 | 16 | { |
Aagrus | 1:c65875995efb | 17 | _c = 0; |
Aagrus | 1:c65875995efb | 18 | _d = 0; |
Aagrus | 1:c65875995efb | 19 | } |
Aagrus | 1:c65875995efb | 20 | MyClassC(int& refB, int const a, int c, int d) : _b(refB), _a(a), _c(c), _d(d) |
Aagrus | 1:c65875995efb | 21 | { |
Aagrus | 1:c65875995efb | 22 | |
Aagrus | 0:76d9c940a794 | 23 | } |
Aagrus | 0:76d9c940a794 | 24 | |
Aagrus | 0:76d9c940a794 | 25 | static int foo() |
Aagrus | 0:76d9c940a794 | 26 | { |
Aagrus | 0:76d9c940a794 | 27 | return 10; |
Aagrus | 0:76d9c940a794 | 28 | } |
Aagrus | 1:c65875995efb | 29 | int GetA(void) {return _a;} |
Aagrus | 1:c65875995efb | 30 | //int GetB(void) {return _b;} |
Aagrus | 1:c65875995efb | 31 | int GetC(void) {return _c;} |
Aagrus | 1:c65875995efb | 32 | int GetD(void) {return _d;} |
Aagrus | 0:76d9c940a794 | 33 | }; |