Multi Level Inheritance

  • + 0 comments
    class Triangle {
        public:
            void display() { cout<<"I am a triangle\n"; }    
    };
    
    class Isosceles: public Triangle {
        public:
            void display() { cout<<"I am an isosceles triangle\n"; }
    };
    
    class Equilateral: public Isosceles {
        public:
            void display() { cout<<"I am an equilateral triangle\n"; }
    };
    
    int main() {  
        Equilateral E1;
        E1.display();
        E1.Isosceles::display();
        E1.Triangle::display();
        return 0;
    }