Subscribe Us

Responsive Advertisement

Advertisement

Multiple Inheritance C++ OOP

 Multiple Inheritance C++ OOP





#include<bits/stdc++.h>

using namespace std;

class M

{

    protected :

    string name;

    public :

        void get_name(string s)

        {

            name=s;


        }

};

class N

{

protected :

    int roll;

public :

    void get_roll(int);

};

void N :: get_roll(int x)

{

    roll=x;

}

class P:public M,public N

{

public :

    void display()

    {

        cout<<name<<endl;

        cout<<roll<<endl;

    }

};

int main()

{

    P p;

    p.get_name("Ujjal");

    p.get_roll(1);

    p.display();

    return 0;

}


Post a Comment

0 Comments