Subscribe Us

Responsive Advertisement

Advertisement

Hybrid Inheritance C++ OOP

 

Hybrid Inheritance C++ OOP




#include<bits/stdc++.h>

using namespace std;

class student

{

    int roll;

    public:

    void get_roll(int x)

    {

        roll=x;


    }

    void show_roll()

    {

        cout<<"Roll : "<<roll<<endl;

    }

};

class test :public student

{

    int sub1,sub2;

public :

       void get_mark(int x,int y)

       {

           sub1=x;

           sub2=y;

       }

       void show_mark()

       {

           cout<<sub1<<endl;

           cout<<sub2<<endl;

       }


};

class sport

{

    int score;

public :

     void get_score(int x)

     {

         score=x;


     }

     void show_score()

     {

         cout<<"score "<<score<<endl;

     }

};

class result : public test,public sport

{


public :

    void display()

    {

        show_roll();

         show_mark();

         show_score();

        // cout<<"total "<<

    }

};


int main()

{

   result r;

   r.get_roll(20020);

   r.get_mark(99,98);

   r.get_score(9);

   r.display();

    return 0;

}


Post a Comment

0 Comments