?? ch12_1.cpp
字號(hào):
//**********************
//** ch12_1.cpp **
//**********************
#include <iostream.h>
class Desk{
public:
Desk(); //構(gòu)造函數(shù)聲明
protected:
int weight;
int high;
int width;
int length;
};
class Stool{
public:
Stool(); //構(gòu)造函數(shù)聲明
protected:
int weight;
int high;
int width;
int length;
};
Desk::Desk() //構(gòu)造函數(shù)定義
{
weight=10;
high=5;
width=5;
length=5;
cout <<weight <<" " <<high <<" "
<<width <<" " <<length <<endl;
}
Stool::Stool() //構(gòu)造函數(shù)定義
{
weight=6;
high=3;
width=3;
length=3;
cout <<weight <<" " <<high <<" "
<<width <<" " <<length <<endl;
}
void fn()
{
Desk da; //自動(dòng)調(diào)用Desk()
Stool sa; //自動(dòng)調(diào)用Stool()
}
void main()
{
fn();
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -