05_OOb: Testat bestanden

This commit is contained in:
Johannes Theiner 2018-11-13 10:56:02 +01:00
parent 745ab41c9d
commit 6e406b3832
1 changed files with 37 additions and 9 deletions

View File

@ -153,25 +153,49 @@ bool HeapObject::assertionsHold(){
} }
class K : public HeapObject class K : public HeapObject {
{ private:
A a;
public: public:
K(){std::cout << "+K ";} K(){std::cout << "+K ";}
~K(){std::cout << "-K ";} ~K(){std::cout << "-K ";}
}; };
class L { class K2 : public HeapObject {
private:
A a;
public:
K2(){
B b;
std::cout << "+K ";}
~K2(){std::cout << "-K ";}
};
class M : public K{
public:
M(){
{
B b;
}
std::cout << "+M ";
}
~M(){std::cout << "-M ";}
};
class L : public M{
public: public:
L(){std::cout << "+L ";} L(){std::cout << "+L ";}
~L(){std::cout << "-L ";} ~L(){std::cout << "-L ";}
}; };
void mod5() {
L *p = new L();
delete p;
}
class M { void testat() {
public: K2 k2;
M(){std::cout << "+M ";} }
~M(){std::cout << "-M ";}
};
@ -191,6 +215,10 @@ int main(int argc, const char * argv[]) {
HeapObject::assertionsHold(); HeapObject::assertionsHold();
std::cout << " ENDE" << std::endl; std::cout << " ENDE" << std::endl;
mod5();
std::cout << std::endl;
testat();
return 0; return 0;
} }