i wanna know ina easy way what do we ,mean by inheritance and hybrid inheritance in c++

Recommended Answers

All 2 Replies

There are so so many tutorials online about this. I'm not sure what you are confused by. As a quick glimpse, consider the following code:

//base class
struct Base{
   int x; 
   virtual ~Base(){};
};
//inherit properties and method from Base class
struct Derived: Base{
   int y;
};

After the derived class inherits from the base class you can access things in base class from derived class. For example,

Derived object;
object.y = 0;
object.x = 0; //this is the base class variable but the base class is part of derived class

That's very brief tutorial, you should really invest in a book or use online and do some research. Hope that helps.

Shortly, inheritence refers to extending/changing the functionality of a class without reimplementing the class. That means, if you have class A and you want to add more (or to change) functionality, you define class B: (inheritance access level: public, protected or private) A which is read as "B inherits A". Depending on the inheritance access level you have or not access to some members of class A (called base or parent class) in class B (called derived or child class).

When you have a cascade of inheritance, it is called multilevel inheritance (e.g., C inherits B which inherits A).

When you inherit more than one class, it is called multiple inheritance (take care of the diamond problem).

When you combine a multilevel inheritance with single inheritance, it is called hybrid inheritance (e.g., D inherits B and C, with B inheriting A).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.