📄 demo_constructor_11.cpp
字号:
//***************************************************
# include <iostream.h>
class A
{
public:
A(int j):age(j),num(age+1) //冒号语法
{
cout<<"age: "<<age<<endl;
cout<<"num: "<<num<<endl;
}
protected: //类成员以其在类中声明的顺序构造
// int num,age; //int num; int age;
int age,num; //int age; int num;
};
void main()
{
A sa(15);
}
// 注意变量n的值!
/* //
age: 15
num: -858993459
Press any key to continue
age: 15
num: 16
Press any key to continue
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -