ch17_1.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:1k
源码类别:
C#编程
开发平台:
Visual C++
- //**********************
- //** 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();
- }