文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
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
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载