Inheritance Syntax of it is
class abc{
};
class abc1:public abc{
};
Some important information that makes you learn more
- Derived class (child) - the class that inherits from another class
- Base class (parent) - the class being inherited from
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
![]()