diff --git a/src/05_OO/b/Testat/main_mp4_OO_b.cpp b/src/05_OO/b/Testat/main_mp4_OO_b.cpp index 25160e8..3a4178a 100644 --- a/src/05_OO/b/Testat/main_mp4_OO_b.cpp +++ b/src/05_OO/b/Testat/main_mp4_OO_b.cpp @@ -153,26 +153,50 @@ bool HeapObject::assertionsHold(){ } -class K : public HeapObject -{ +class K : public HeapObject { +private: + A a; public: - K(){std::cout << "+K ";} + K(){std::cout << "+K ";} ~K(){std::cout << "-K ";} }; -class L { +class K2 : public HeapObject { +private: + A a; public: - L(){std::cout << "+L ";} - ~L(){std::cout << "-L ";} + K2(){ + B b; + std::cout << "+K ";} + ~K2(){std::cout << "-K ";} }; - -class M { +class M : public K{ public: - M(){std::cout << "+M ";} + M(){ + { + B b; + } + std::cout << "+M "; + } ~M(){std::cout << "-M ";} }; +class L : public M{ +public: + L(){std::cout << "+L ";} + ~L(){std::cout << "-L ";} +}; + +void mod5() { + L *p = new L(); + delete p; +} + +void testat() { + K2 k2; +} + int main(int argc, const char * argv[]) { @@ -191,6 +215,10 @@ int main(int argc, const char * argv[]) { HeapObject::assertionsHold(); std::cout << " ENDE" << std::endl; + mod5(); + std::cout << std::endl; + testat(); + return 0; }