Inheritance Syntax of it is
class abc{
};
class abc1:public abc{
};
Three are mainly Four Types of Inheritance
- Single Inheritance.
- Multiple Inheritance.
- Multilevel Inheritance.
- Hierarchical Inheritance.
Some important information
- When if you choose any datamember C++ defaults private in it.
Basic Program
INPUT
#include <iostream> #include<conio.h> class abc{ public: void add() { cout<<"Hello"; } }; class abc2:public abc{ public: void sub() { add(); } }; main() { abc2 a1; a1.sub(); getch(); }
OUTPUT
![]()