Multi Level Inheritance

  • + 0 comments
    #include <iostream>
    using namespace std;
    
    class Triangle{
        public:
        void tri(){
            cout<<"I am a triangle\n";
        }
    };
    
    class Isosceles: public Triangle{
        public:
        void iso(){
            cout<<"I am an isosceles triangle\n";
        }
        
    };
    
    class Equilateral: public Isosceles{
        public:
        void equi(){
            cout<<"I am an equilateral triangle\n";
        }
    };
    
    int main(){
        Equilateral eq;
        eq.equi();
        eq.iso();
        eq.tri();
        return 0;
    }