ch12_1.cpp
来自「本文档是(作者:钱能)《C++程序设计教程》系列的部分辅助代码。 选题编辑:张」· C++ 代码 · 共 56 行
CPP
56 行
//**********************
//** ch12_1.cpp **
//**********************
#include <iostream.h>
class Desk{
public:
Desk(); //构造函数声明
protected:
int weight;
int high;
int width;
int length;
};
class Stool{
public:
Stool(); //构造函数声明
protected:
int weight;
int high;
int width;
int length;
};
Desk::Desk() //构造函数定义
{
weight=10;
high=5;
width=5;
length=5;
cout <<weight <<" " <<high <<" " <<width <<" " <<length <<endl;}
Stool::Stool() //构造函数定义
{
weight=6;
high=3;
width=3;
length=3;
cout <<weight <<" " <<high <<" " <<width <<" " <<length <<endl;}
void fn()
{
Desk da; //自动调用Desk()
Stool sa; //自动调用Stool()
}
void main()
{
fn();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?