📄 p2-128.cpp
字号:
#include<iostream.h>
//定义最低层基类First,它作为其他类的基类
class First {
int val1;
public:
First() {
cout<<"The First initialized"<<endl;
}
~First() {
cout<<"The First destroyed"<<endl;
}
};
//定义派生类Second,它作为其他类的基类
class Second :public First { //默认为private模式
int val2;
public:
Second() {
cout<<"The Second initialized"<<endl;
}
~Second() {
cout<<"The Second destroyed"<<endl;
}
};
//定义最上层派生类Three
class Three :public Second {
int val3;
public:
Three() {
cout<<"The Three initialized"<<endl;
}
~Three() {
cout<<"The Three destroyed"<<endl;
}
};
//main()函数中测试构造函数和析构函数的执行情况
main() {
Three t1;
cout<<"---- Use the t1----"<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -