Hybrid inheritance in C++ occurs when two or more types of inheritance are combined.

#include <iostream> using namespace std; class A { protected: int a; public: void get_a() { std::cout << "Enter the value of 'a' : " << std::endl; cin>>a; } }; class B : public A { protected: int b; public: void get_b() { std::cout << "Enter the value of 'b' : " << std::endl; cin>>b; } }; class C { protected: int c; public: void get_c() { std::cout << "Enter the value of c is : " << std::endl; cin>>c; } }; class D : public B, public C { protected: int d; public: void mul() { get_a(); get_b(); get_c(); std::cout << "Multiplication of a,b,c is : " <<a*b*c<< std::endl; } }; int main() { D d; d.mul(); return 0; }
Output:
Enter the value of 'a' :
10
Enter the value of 'b' :
20
Enter the value of c is :
30
Multiplication of a,b,c is : 6000
Join Our Community
Join our WhatsApp Group To know more about Programming Language tips, tricks and knowledge about and how to start learning any programming language.