?? 程序11.2:調(diào)用構(gòu)造符和析構(gòu)符的順序.cpp
字號:
/* 程序11.2:調(diào)用構(gòu)造符和析構(gòu)符的順序.cpp:*/
#include<iostream> //包含頭文件
using namespace std; //使用名字空間std
class Base //聲明基類Base
{
public:
Base() //聲明基類構(gòu)造符函數(shù)
{
cout<<"調(diào)用基類構(gòu)造符函數(shù)"<<endl;
}
~Base() //聲明基類析構(gòu)符函數(shù)
{
cout<<"調(diào)用基類析構(gòu)符函數(shù)"<<endl;
}
};
class Derived:public Base//聲明子類Derived
{
public:
Derived() //聲明子類構(gòu)造符函數(shù)
{
cout<<"調(diào)用子類構(gòu)造符函數(shù)"<<endl;
}
~Derived() //聲明基類析構(gòu)符函數(shù)
{
cout<<"調(diào)用子類析構(gòu)符函數(shù)"<<endl;
}
};
int main()
{
Derived obj; //聲明子類對象
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -