Inheritance is a basic object oriented feature in which one class acquires and inherit the properties of another class. All the properties of the Base Class ( also known as the Parent Class or Super class ) are present in the Derived Class ( also known as the Child Class or Sub class ). Hybrid Inheritance can also be achieved using a combination of Multilevel and Hierarchical inheritance.
In this program, we have four classes: grandfather, father, mother, and son.
#include<iostream> using namespace std; //Hybrid Inheritance in C++ Programming class grandfather { public: void house() { cout<<"3BHK House."<<endl; } }; class father:public grandfather { public: void land() { cout<<"5Arcs of Land."<<endl; } }; class mother { public: void gold() { cout<<"25g of Gold."<<endl; } }; class son:public father,public mother { public: void car() { cout<<"Audi Car."<<endl; } }; int main() { son o; o.house(); o.land(); o.car(); o.gold(); return 0; }
3BHK House. 5Arcs of Land. Audi Car. 25g of Gold.To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions