home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / m / m003_1 / sb_bc.ddi / BC / CH4 / PROG4-9.CPP < prev   
Encoding:
C/C++ Source or Header  |  1991-12-10  |  926 b   |  80 lines

  1. //  PROG4-9.CPP
  2.  
  3. #include<stdio.h>
  4.  
  5. //////////  Base1 Class
  6. //////////
  7. class Base1
  8. { private:
  9.     int base1 ;
  10.  
  11.   public:
  12.     Base1(int i) ;
  13.     void print1(void) ;
  14. } ;
  15.  
  16.  
  17. Base1::Base1(int i)
  18. {
  19.   base1 = i ;
  20. }
  21.  
  22. void Base1::print1(void)
  23. {
  24. }
  25.  
  26.  
  27. //////////  Base2 Class
  28. //////////
  29. class Base2
  30. { private:
  31.     char base2 ;
  32.  
  33.   public:
  34.     Base2(int i) ;
  35.     void print2(void) ;
  36. } ;
  37.  
  38.  
  39. Base2::Base2(int i)
  40. {
  41.   base2 = i ;
  42. }
  43.  
  44. void Base2::print2(void)
  45. {
  46. }
  47.  
  48.  
  49. ///////////  Derived Class
  50. //////////
  51. class Derived : public Base1, private Base2
  52. { private :
  53.     float derived ;
  54.  
  55.   public :
  56.     Derived(int i, char c, float f) ;
  57.     void list(void) ;
  58. } ;
  59.  
  60.  
  61. Derived::Derived(int i, char c, float f) : Base1(i), Base2(c)
  62. {
  63.   derived = f ;
  64. }
  65.  
  66. void Derived::list(void)
  67. {
  68.   print1() ;
  69.   print2() ;
  70. }
  71.  
  72.  
  73. int main()
  74. { Derived a(2,'a',3.0) ;
  75.  
  76.   a.print1() ;
  77.   a.print2() ;
  78. }
  79.  
  80.