public inheritance from three parent classes : Public « Class « C++






public inheritance from three parent classes

  
#include <iostream>
using namespace std;
class One{
 public:
  One(void) { cout << "Constructor for One\n"; };
};

class Two{
 public:
  Two(void) { cout << "Constructor for Two\n"; };
};

class Three {
 public:
  Three(void) { cout << "Constructor for Three\n"; };
};

class Derived: public One, public Three, public Two 
{
 public:
   Derived(void) : One(), Two(), Three() 
   {
     cout << "Derived constructor called\n"; 
   };
};

int main(void)
{
   Derived my_class;
}
  
    
  








Related examples in the same category

1.Illustrates the use of a public variableIllustrates the use of a public variable
2.Assign the public object member address to a pointerAssign the public object member address to a pointer
3.public class extending
4.field in struct is public by default
5.Class with only public fields and methods
6.Virtual public inheritance
7.public data field