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

  1. // Chap27_2.cpp
  2. #include <iostream.h>
  3.  
  4. //Furniture - more fundamental concept; this class
  5. //            has "weight" as a property
  6. class Furniture
  7. {
  8.   public:
  9.    Furniture()
  10.    {
  11.    }
  12.    int weight;
  13. };
  14.  
  15. class Bed : public Furniture
  16. {
  17.   public:
  18.    Bed()
  19.    {
  20.    }
  21.    sleep()
  22.    {
  23.    }
  24. };
  25. class Sofa : public Furniture
  26. {
  27.   public:
  28.    Sofa()
  29.    {
  30.    }
  31.    void watchTV()
  32.    {
  33.    }
  34. };
  35. class SleeperSofa : public Bed, public Sofa
  36. {
  37.   public:
  38.    SleeperSofa()
  39.    {
  40.    }
  41.    void foldOut()
  42.    {
  43.    }
  44. };
  45.  
  46. void fn()
  47. {
  48.    SleeperSofa ss;
  49.    cout << "weight = " 
  50.         << ss.weight     //problem solved; right?
  51.         << "\n";
  52. }
  53.  
  54. int main()
  55. {
  56.    fn();
  57.    return 0;
  58. }
  59.