Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ multilevel inheritance

#include <iostream>
 
class A {    // A is the base class
public:
  int a;
 
  A() { std::cout << "Constructing A
"; }
};
 
class B: public A {    // class B inherits from class A
public:
  int b;
 
  B() { std::cout << "Constructing B
"; }
};
 
class C: public B {    // class C inherits from class B
public:
  int c;
 
  C() { std::cout << "Constructing C
"; }
};
 
int main() {
  C example; 
 
  return 0;
}
 
PREVIOUS NEXT
Tagged: #multilevel #inheritance
ADD COMMENT
Topic
Name
5+6 =