home *** CD-ROM | disk | FTP | other *** search
/ C++ for Dummies (3rd Edition) / C_FD.iso / CHAP27 / CHAP27_1.CPP next >
C/C++ Source or Header  |  1996-09-15  |  693b  |  48 lines

  1. // Chap27_1.cpp
  2. class Bed
  3. {
  4.   public:
  5.    Bed()
  6.    {
  7.    }
  8.    void sleep()
  9.    {
  10.    }
  11.    int weight;
  12. };
  13. class Sofa 
  14. {
  15.   public:
  16.    Sofa()
  17.    {
  18.    }
  19.    void watchTV()
  20.    {
  21.    }
  22.    int weight;
  23. };
  24.  
  25. //SleeperSofa - is both a Bed and a Sofa
  26. class SleeperSofa : public Bed, public Sofa
  27. {
  28.   public:
  29.    SleeperSofa()
  30.    {
  31.    }
  32.    void foldOut()
  33.    {
  34.    }
  35. };
  36.  
  37. int main()
  38. {
  39.    SleeperSofa ss;
  40.    //you can watch TV on a sleeper sofa...
  41.    ss.watchTV();         //Sofa::watchTV()
  42.    //...and then you can fold it out...
  43.    ss.foldOut();          //SleeperSofa::foldOut()
  44.    //...and sleep on it (sort of)
  45.    ss.sleep();           //Bed::sleep()
  46.    return 0;
  47. }
  48.