Hybrid Inheritance In cpp

Hybrid Inheritance In cpp

PROGRAM:
  1. #include<iostream>
  2. using namespace std;
  3. class A{
  4. public:
  5. A(){
  6. cout<<"\n grand parent";
  7. }
  8.  
  9. };
  10. class B:public A{
  11. public:
  12. B(){
  13.  
  14. cout<<"\n parent1";
  15. }
  16. };
  17. class C:public A{
  18. public:
  19. C(){
  20. cout<<"\n parent2";
  21. }
  22. };
  23. class D:public B,public C{
  24. public:
  25. D(){
  26. cout<<"\n child class";
  27. }
  28. };
  29. int main(){
  30. D d;
  31. return 0;
  32. }
  33.  

Comments

Popular posts from this blog

Introduction to ChatGPT: Explain what ChatGPT is, how it works, and what it is used for.

Multi Level Inheritance In cpp