- 论坛徽章:
- 1
|
本帖最后由 daxiguagg 于 2014-08-14 21:23 编辑
class atest
{
public:
atest();
~atest();
int a;
int b;
protected:
private:
};
class btest:public atest
{
public:
btest();
~btest();
int a;
int b;
protected:
private:
};
atest::atest()
{
this->a=1;
}
atest::~atest()
{
this->a=0;
}
btest::btest()
{
this->a=1;
}
btest::~btest()
{
this->a=0;
}
int _tmain(int argc, _TCHAR* argv[])
{
atest *at=new btest();//构造函数调用顺序正确,调用了atest(),然后调用了btest()
delete at; //这里delete at,为什么只调用了atest::~atest()的析构函数,没有调用btest::~btest()析构函数呢???
Sleep(INFINITE);
return 0;
} |
|