Hybrid Inheritance in C++

Do you know what information the article is going to tell you ?. Hybrid Inheritance in C++ We are going to see clearly about this.

Hybrid Inheritance in C++

Hybrid Inheritance in C++

#include <iostream> 
using namespace std; 
  
// base class  
class Vehicle  
{ 
  public: 
    Vehicle() 
    { 
      cout << "This is a Vehicle" << endl; 
    } 
}; 
  
//base class 
class Fare 
{ 
    public: 
    Fare() 
    { 
        cout<<"Fare of Vehicle\n"; 
    } 
}; 
  
// first sub class  
class Car: public Vehicle 
{ 
  
}; 
  
// second sub class 
class Bus: public Vehicle, public Fare 
{ 
      
}; 
  
// main function 
int main() 
{    
    // creating object of sub class will 
    // invoke the constructor of base class 
    Bus obj2; 
    return 0; 
}

Final Words

Hybrid Inheritance in C++ We hope you find the information you are looking for through this article and we hope all your doubts are resolved through this article.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment