# include <iostream>
using namespace std;
struct A
{
int a;
A()
{
cout<<"I am A"<<endl;
a=1;
}
~A()
{
cout<<"I am A destruct"<<endl;
}
};
struct B:public A
{
B()
{
cout<<"I am B"<<endl;
a=0;
}
~B()
{
cout<<"I am B destruct"<<endl;
}
};
int main()
{
B *b=new B;
A *q=b;
cout<<q->a<<endl;
}
动态继承
最新推荐文章于 2012-10-23 21:09:16 发布