Multi Level Inheritance

Sort by

recency

|

83 Discussions

|

  • + 0 comments

    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"; } };

    //Write your code here.

    int main(){

    Equilateral eqr;
    eqr.equilateral();
    eqr.isosceles();
    eqr.triangle();
    return 0;
    

    }

  • + 0 comments
    #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";
              }
    };
    
    //Write your code here.
    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;
    }
    
  • + 0 comments
    #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;
    }
    
  • + 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;
    }
    
  • + 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;
    }