WRITE A PROGRAM FOR MULTI INHERITANCE IN C++

 Que- Make a program for simple inheritance?

#include<iostream>
using namespace std;

class a
{
protected:
    char name[10];
    int roll, age, classroom;
};
class b: public a
{
public:
    void getdata ()
    {
        cout<<"enter your name: ";
        cin>>name;
        cout<<"enter your class no. : ";
        cin>>classroom;
        cout<<"enter your roll no. : ";
        cin>>roll;
        cout<<"enter your age: ";
        cin>>age;
        cout<<endl ;
    }
};
class c: public b
{
public:
    void display ()
    {
        cout<<"your name :"<<name<<endl<<"your class no. :"<<classroom<<endl<<"your roll no. :"<<roll<<endl<<"your age :"<<age<<endl;
    }
};
int main()
{
    c ob;
    ob. getdata ();
    ob. display ();
    return 0;
}

Result:-



Post a Comment

Previous Post Next Post