diff --git a/src/05_OO/b/MP/main_mp4_OO_b.cpp b/src/05_OO/b/MP/main_mp4_OO_b.cpp index 907263c..cf8412a 100644 --- a/src/05_OO/b/MP/main_mp4_OO_b.cpp +++ b/src/05_OO/b/MP/main_mp4_OO_b.cpp @@ -152,27 +152,27 @@ bool HeapObject::assertionsHold(){ return true; } - class K : public HeapObject { public: - K(){std::cout << "+K ";} + K(){std::cout << "+K ";} ~K(){std::cout << "-K ";} }; -class L { +class M : public K{ +public: + //B b; für Modifikation 5 einkommentieren + M(){std::cout << "+M ";} + ~M(){std::cout << "-M ";} +}; + +class L : public M{ public: L(){std::cout << "+L ";} ~L(){std::cout << "-L ";} }; -class M { -public: - M(){std::cout << "+M ";} - ~M(){std::cout << "-M ";} -}; - void pattern1() { B b; { @@ -187,6 +187,11 @@ void pattern2() { A a; } +B AtoB(A &a) { + B &b = reinterpret_cast(a); + return b; +} + void pattern3() { A a1; { @@ -194,6 +199,8 @@ void pattern3() { { B b; } + } + { C c; } } @@ -222,6 +229,9 @@ int main(int argc, const char * argv[]) { pattern2(); std::cout << std::endl; pattern3(); + std::cout << std::endl; + L *p = new L(); + delete p; return 0; }