Privmult.cpp
Upload User: dq031136
Upload Date: 2022-08-08
Package Size: 802k
Code Size: 1k
Development Platform:

C++ Builder

  1. #include <iostream.h>
  2. class One 
  3. {
  4.  public:
  5.   One(void) 
  6.   { 
  7.     cout << "Constructor for Onen"; 
  8.     one = 1;
  9.   };
  10.   int one;
  11. };
  12. class Two 
  13. {
  14.  public:
  15.   Two(void) 
  16.   { 
  17.     cout << "Constructor for Twon";
  18.     two = 2;
  19.   };
  20.   int two;
  21. };
  22. class Three 
  23. {
  24.  public:
  25.   Three(void) 
  26.   { 
  27.     cout << "Constructor for Threen"; 
  28.     three = 3;
  29.   };
  30.   int three;
  31. };
  32. class Derived: private One, private Three, public Two 
  33. {
  34.  public:
  35.    Derived(void) : One(), Two(), Three() 
  36.    {
  37.      cout << "Derived constructor calledn"; };
  38.    void show_value(void) { cout << one << two << three << endl; };
  39. };
  40. void main(void)
  41.  {
  42.    Derived my_class;
  43.    my_class.show_value();
  44.    cout << my_class.two;
  45.  }