05_OOb: Vorbereitungen für Testat

Signed-off-by: Johannes Theiner <j.theiner@live.de>
This commit is contained in:
Johannes Theiner 2018-11-13 08:48:24 +01:00
parent e46a332efe
commit 745ab41c9d
1 changed files with 19 additions and 9 deletions

View File

@ -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<B &>(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;
}