# Hacker Rank solution for Multi Level Inheritance In C++

Problem:- Multi Level Inheritance Hacker Rank Solution or Multi Level Inheritance hacker rank solution c++ orMulti Level Inheritance in java or Multi Level Inheritance solution or Multi Level Inheritance solution in C++ or Multi Level Inheritance hacker rank solution in Java or Multi Level Inheritance hacker rank solution c++ or Multi Level Inheritance hacker rank solution c++ or Multi Level Inheritance program in c or Multi Level Inheritance solution in C or Hacker Rank Solution For Multi Level Inheritance in C++ or Multi Level Inheritance in C++ or Hacker Rank solution for Multi Level Inheritance in C++.

Explanation:- Suppose we have a class A which is the base class and we have a class B which is derived from class A and we have a class C which is derived from class B, we can access the functions of both class A and class B by creating an object for class C. This is called Multi-Level inheritance. (B inherits A and C inherits B.)

Check- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard Domain.

Copy the full solution or colored code and paste into the hacker rank editor and click to Run Code if the code runs successfully then click to Submit Code. Before pasting the code into the editor make sure you have chosen c++ editor in the top right drop down option.

Solution:-

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

class Triangle
{
public:
void triangle()
{
cout<<"I am a triangle\n";
}
};

class Isosceles : public Triangle
{
public:
void isosceles()
{
cout<<"I am an isosceles triangle\n";
}
};

class Equilateral:public Isosceles
{
public:
void equilateral()
{
cout<<"I am an equilateral triangle\n";
}
};

int main()
{

Equilateral eqr;

eqr.equilateral();

eqr.isosceles();

eqr.triangle();

return 0;

}

Output:-

Previous Post
Next Post

#### post written by: Ghanendra Yadav

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.