ch17_1.cpp
来自「本文档是(作者:钱能)《C++程序设计教程》系列的部分辅助代码。 选题编辑:张」· C++ 代码 · 共 39 行
CPP
39 行
//**********************
//** ch17_1.cpp **
//**********************
#include<iostream.h>
class Bed{
public:
Bed() :weight(0){}
void Sleep(){ cout <<"Sleeping...\n"; }
void SetWeight(int i){ weight =i; }
protected:
int weight;
};
class Sofa{
public:
Sofa() :weight(0){}
void WatchTV(){ cout <<"Watching TV.\n"; }
void SetWeight(int i){ weight =i; }
protected:
int weight;
};
class SleeperSofa :public Bed, public Sofa{
public:
SleeperSofa(){}
void FoldOut(){ cout <<"Fold out the sofa.\n"; }
};
void main()
{
SleeperSofa ss;
ss.WatchTV();
ss.FoldOut();
ss.Sleep();
cin.get();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?