# include < iostream >
using namespace std
;
class A
{
public:
virtual void hello()
{
cout
<< "this:" << this << endl
;
cout
<< " A::hel1o" << endl
;
};
virtual void bye()
{
cout
<< "this:" << this << endl
;
cout
<< "A::bye" << endl
;
cout
<< "this:" << this << endl
;
};
};
class B :public A
{
public:
virtual void hello() { cout
<< "B::he11o" << endl
; };
B()
{
cout
<< "B::B()" << endl
;
cout
<< "this:" << this << endl
;
hello();
cout
<< "this:" << this << endl
;
}
~B()
{
cout
<< "this:" << this << endl
;
bye();
cout
<< "this:" << this << endl
;
}
};
class C :public B
{
public:
virtual void hello() { cout
<< "C::hello" << endl
; }
C()
{
cout
<< "C::C()" << endl
;
}
};
int main()
{
C obj
;
cout
<< "C类对象obj的地址:&obj="<<&obj
<< endl
;
return 0;
}
转载请注明原文地址:https://blackberry.8miu.com/read-7172.html