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,26 +153,50 @@ 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: public:
L(){std::cout << "+L ";} K2(){
~L(){std::cout << "-L ";} B b;
std::cout << "+K ";}
~K2(){std::cout << "-K ";}
}; };
class M : public K{
class M {
public: public:
M(){std::cout << "+M ";} M(){
{
B b;
}
std::cout << "+M ";
}
~M(){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[]) { int main(int argc, const char * argv[]) {
@ -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;
} }