文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++程序习题-验证继承的构造函数,析构函数[5.8]

C++程序习题-验证继承的构造函数,析构函数[5.8]

时间:2010-11-25  来源:chengxiaopeng

代码代码:
 

#include <iostream>
using namespace std;

class A
{
    public:
    A(){ cout << "construction A" << endl;}
    ~A(){cout << "destructing A" << endl;}
};

class B: public A
{
    public:
    B(){ cout << "construction B" << endl;}
    ~B(){cout << "destructing B" << endl;}
};

class C: public B
{
    public:
    C(){ cout << "construction C" << endl;}
    ~C(){cout << "destructing C" << endl;}
};

int main()
{
    C c1;
    c1.~C();
    system("pause");
    return 0;
}


运行结果:
construction A
construction B
construction C
destructing C
destructing B
destructing A
相关阅读 更多 +
排行榜 更多 +
粉末星战 v1.0.0 安卓版

粉末星战 v1.0.0 安卓版

休闲益智 下载
粉末星战 v1.0.0 安卓版

粉末星战 v1.0.0 安卓版

休闲益智 下载
火线反恐部队 v1.2 安卓版

火线反恐部队 v1.2 安卓版

飞行射击 下载