#include <iostream>
using namespace std;
class B
{
public:
int i, j;
B(int x = 999) :j(x),i(j)
{
cout << "B::B() invoked\n" << endl;
}
~B()
{
cout << "B::~B() invoked\n" << endl;
}
};
class D : public B
{
public:
D()
{
cout << "D::D() invoked\n" <<endl;
}
~D()
{
cout << "D::~D() invoked\n" << endl;
}
};
void main()
{
D d;
cout << "d.i" << d.i << endl;
cout << "d.j=" << d.j << endl;
}
B::B() invoked
D::D() invoked
d.i-858993460
d.j=999
D::~D() invoked
B::~B() invoked
请按任意键继续. . .