Hierarchical Inheritance

Estudies4you

4. Hierarchical Inheritance

It refers to the process of deriving many classes from a single base class. All the derived classes can be further inherited by some other classes in the same way.
Hierarchical Inheritance definition,define Hierarchical Inheritance,discuss Hierarchical Inheritance,explain Hierarchical Inheritance,explain about Hierarchical Inheritance,Hierarchical Inheritance notes,Hierarchical Inheritance study material,Hierarchical Inheritance syntax,syntax for Hierarchical Inheritance,examples for Hierarchical Inheritance,Hierarchical Inheritance examples,programs for Hierarchical Inheritance,Hierarchical Inheritance programs,estudies4you,c++ lecture notes,c++ study material,oops using c++ notes jntuh
Figure: Hierarchical Inheritance
Syntax
class A
{
--------
};
class B: visibility A
{
--------
};
class C: visibility A
{
--------
}
class D: visibility B
{
--------
};
Example
class Automobiles
{
// body
};
class Cars : public Automobiles
{
// body
};
class Bikes :; public Automobiles
{
// body

};

Program
#include <iostream>
using namespace std;
class A
{
public:
int x;
void get()
{
cout << “Enter value of x:”;
cin >> x;
}
};
class B : public A
{
public:
void Square()
{
cout << “The square of the given number is: ” <<x * x;
}
};
class C : public A
{
public: :
void cube()
{
cout << “\nThe cube of the given number is: ” << x * x *x;
}
};
int main()
{
B obl;
C ob2;
ob1.get();
ob1.Square();
ob2.cube();
return 0;
}
Output
Hierarchical Inheritance definition,define Hierarchical Inheritance,discuss Hierarchical Inheritance,explain Hierarchical Inheritance,explain about Hierarchical Inheritance,Hierarchical Inheritance notes,Hierarchical Inheritance study material,Hierarchical Inheritance syntax,syntax for Hierarchical Inheritance,examples for Hierarchical Inheritance,Hierarchical Inheritance examples,programs for Hierarchical Inheritance,Hierarchical Inheritance programs,estudies4you,c++ lecture notes,c++ study material,oops using c++ notes jntuh

To Top