C++ Program – Multilevel Inheritance

by Nideesh C on May 2, 2011 · 0 comments

in C++




//Downloaded From theonlinetutorials.com
//A program to illustrate multilevel inheritance
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class admin
{
char name[30];
int adno;
public:
void getadmin();
void putadmin();
};

void admin::getadmin()
{
cout<<"\n\nEnter the name:";
gets(name);
cout<<"\nEnter the admission no:";
cin>>adno;
}

void admin::putadmin()
{
cout<<"\nName of the student:";
cout<<name;
cout<<"\nAdmission no:";
cout<<adno;
}
class acad
{
int rno;
float totmrks;
public:
void get_acad();
void put_acad();
};
void acad::get_acad()
{
cout<<"\nEnter the roll no:";
cin>>rno;
cout<<"\nEnter total marks:";
cin>>totmrks;
}
void acad::put_acad()
{
cout<<"\nRoll no:",
cout<<rno;
cout<<"\nTotal marks:";
cout<<totmrks;
}

class school:public admin,public acad
{
char sports[15];
char house[15];
public:
void admin();
void academics();
void get_school();
void put_school();
};
void school::get_school()
{
getadmin();
get_acad();
cout<<"\nEnter the house:";
gets(house);
cout<<"\nEnter the sport chosen:";
gets(sports);
}
void school::put_school()
{
putadmin();
put_acad();
cout<<"\nHouse:";
cout<<house;
cout<<"\nSports chosen:";
cout<<sports;
}

void main()
{
clrscr;
school obj[10];
int i,j,n;
cout<<"\nEnter the number of students:";
cin>>n;
cout<<"\nEnter student details:";
for(i=0;i<n;i++) //Enter student details
{
obj[i].get_school();
}
cout<<"\nThe student details are:";
for(j=0;j<n;j++) //display student details
{
obj[j].put_school();
}
getch();
}



Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C++ program – illustrate Multilevel Inheritance
  2. C++ program – Using class to generate mark sheet using multiple inheritance
  3. C++ program – Print student details using constructor and destructor
  4. C++ Program – Classes and objects
  5. C++ program – implement three classes using multiple inheritance

Leave a Comment

Previous post:

Next post: