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

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