C++ program using multiple inheritance





This program consists of two base classes and one derived class. The base class “Stuinfo” contains the data members: name, roll. And another base class “Stuacademic info” contains the data members: course and semester.

The derived class “stuaddressinfo” contains the data members: address only.

#include<iostream.h>

#include<conio.h>

Class Stuinfo

{

Private:

Char name [25];

Int roll;

Public:

Void getdata ()

{

Cout<<”\n Enter name”;

Cin>>name;

Cout<<”\n Enter roll”;

Cin>> roll;

}

Void display ()

{

Cout<<”\n name=”<<name;

Cout<<”\n Roll number”<<roll;

}

};

Class Stuacademicinfo

{

Private:

Char course [25];

Char semester [15];

Public:

Void getdata ()

{

Cout<<”\n Enter course name”;

Cin>>course;

Cout<<”\n Enter semester”;

Cin>>semester;

}

Void display ()

{

Cout<<”\n Course “<<course;

Cout<<”\n semester”<<semester;

};

Class stuaddressinfo: public Stuinfo, public Stuacademicinfo

{

Private:

Char address [25];

Public:

Void getdata ()

{

Stuinfo:: getdata ();

Stuacademicinfo:: getdata ();

Cout<<”\n Enter the address”;

Cin>>address;

}

Void display ()

{

Stuinfo:: display ();

Stuacademic:: display ();

Cout <<”\n Address”<<address;

};

Void main ()

{

Stuaddressinfo obj;

Obj .getdata ();

Obj.dispay ();

getch ();

}



Related posts:

  1. Inheritance in C++ Inheritance in C++ Inheritance is one of the most important...
  2. Abstract Base Class Abstract base class It is a class which consists of...
  3. Array of class objects Array of class objects and single inheritance A program consisting...
  4. C++ Program Using Structure A structure can be said as, the collection of  datas...
  5. C++ Program Using Friend Function Friend function is used to access private, public and protected...