[C++] 纯文本查看 复制代码
#include <iostream>
class a
{
public:
a()
{
std::cout << "into A construct function !" << std::endl;
}
~a()
{
std::cout << "into A destruct function !" << std::endl;
}
};
class b :public a
{
public:
b()
{
std::cout << "into B construct function !" << std::endl;
}
~b()
{
std::cout << "into B destruct function !" << std::endl;
}
};
class c :public b
{
public:
c()
{
std::cout << "into C construct function !" << std::endl;
}
~c()
{
std::cout << "into C destruct function !" << std::endl;
}
};
int main()
{
c *z = new c;
delete z;
return 0;
}
纯C++的语法,本人小白,因为有个群里有人问这个问题,就敲了下,也就顺便放到坛子里给需要的人了,这样就很清楚的能理解继承时调用的先后顺序了。
|