Posts

Showing posts from January, 2021

Inheritance Concept

Image
Descriptions : To inherit fields and methods from one class to another.  It includes two class. Derived Class - the class that inherits from another class Base Class - the class being inherited from Types: 1. Single Inheritance 2. Multilevel Inheritance 3. Hierarchical Inheritance 4. Multiple Inheritance ( using  Interface) Example : Single Inheritance In the below example there are the two classes declared. One class is ClassA and another one is ClassB. Here ClassB is inherted the classA. ClassB is considered as derived class and ClassA is considered as base class. Class is inherited by special character ":" colon. Below in the main function, there is the object of the ClassB is created and it is also used the member of the classA. Output: