ch17_1.cpp
Upload User: puke2000
Upload Date: 2022-07-25
Package Size: 912k
Code Size: 1k
Category:

CSharp

Development Platform:

Visual C++

  1. //**********************
  2. //**    ch17_1.cpp    **
  3. //**********************
  4. #include<iostream.h>
  5. class Bed{
  6. public:
  7.   Bed() :weight(0){}
  8.   void Sleep(){ cout <<"Sleeping...n"; }
  9.   void SetWeight(int i){ weight =i; }
  10. protected:
  11.   int weight;
  12. };
  13. class Sofa{
  14. public:
  15.   Sofa() :weight(0){}
  16.   void WatchTV(){ cout <<"Watching TV.n"; }
  17.   void SetWeight(int i){ weight =i; }
  18. protected:
  19.   int weight;
  20. };
  21. class SleeperSofa :public Bed, public Sofa{
  22. public:
  23.   SleeperSofa(){}
  24.   void FoldOut(){ cout <<"Fold out the sofa.n"; }
  25. };
  26. void main()
  27. {
  28.   SleeperSofa ss;
  29.   ss.WatchTV();
  30.   ss.FoldOut();
  31.   ss.Sleep();
  32.   cin.get();
  33. }