📄 overloadcon.cpp
字号:
#include <iostream.h>
class Box
{
private:
int height, width, depth;
public:
Box() { height=0; width=0; depth=0; } // 避免给成员变量赋不安全的值
Box(int ht, int wd, int dp) { height=ht; width=wd; depth=dp; } // 重载构造函数
int Volume() { return height*width*depth; }
};
void main()
{
Box box1;
Box box2(10, 15, 20);
cout<<"Volume1="<<box1.Volume()<<", Volume2="<<box2.Volume()<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -