Research Area

Ashutosh Dubey

Wednesday, December 16, 2009

MULTILEVEL INHERITANCE

#include<iostream.h>


#include<conio.h>

class bio

{

char name[20];

char sem[20];

int age;

int rn;



public:

void getbio();

void showbio();

};



class marks :public bio

{

char sub[10];

float total;

public:

void getm();

void showm();

};



class final:public marks

{

int phno;

public:

void getph();

void showph();

};



void bio::getbio()

{

cout<<"enter name";

cin>>name;

cout<<"enter sem";

cin>>sem;

cout<<"enter age";

cin>>age;

cout<<"enter rollno";

cin>>rn;

}

void bio:: showbio()

{

cout<<"name="<<name;

cout<<"semester="<<sem;

cout<<"age="<<age;

cout<<"rn"<<rn;

}



void marks::getm()

{

cout<<"enter subject name";

cin>>sub;

cout<<"enter marks";

cin>>total;

}





void marks::showm()

{

cout<<sub<<total;

}



void final::getph()

{

cout<<"enter phno";

cin>>phno;

}

void final::showph()

{

cout<<"phoneno"<<phno;

}



void main()

{

final f;

f.getbio();

f.getm();

f.getph();

f.showbio();

f.showm();

f.showph();

getch();

}

No comments: