Your Ad Here

Sunday, June 1, 2008

Multilevel Inheritance

/********* IMPLEMENTATION OF MULTILEVEL INHERITANCE *********/

#include< iostream.h>
#include< conio.h>

class student // Base Class
{
protected:
int rollno;
char *name;
public:
void getdata(int b,char *n)
{
rollno = b;
name = n;
}
void putdata(void)
{
cout< < " The Name Of Student \t: "< < name< < endl;
cout< < " The Roll No. Is \t: "< < rollno< < endl;
}
};

class test:public student // Derieved Class 1
{
protected:
float m1,m2;
public:
void gettest(float b,float c)
{
m1 = b;
m2 = c;
}
void puttest(void)
{
cout< < " Marks In CP Is \t: "< < m1< < endl;
cout< < " Marks In Drawing Is \t: "< < m2< < endl;
}
};

class result:public test // Derieved Class 2
{
protected:
float total;
public:
void displayresult(void)
{
total = m1 + m2;
putdata();
puttest();
cout< < " Total Of The Two \t: "< < total< < endl;
}
};

void main()
{
clrscr();
int x;
float y,z;
char n[20];
cout< < "Enter Your Name:";
cin>>n;
cout< < "Enter The Roll Number:";
cin>>x;
result r1;
r1.getdata(x,n);
cout< < "ENTER COMPUTER PROGRAMMING MARKS:";
cin>>y;
cout< < "ENTER DRAWING MARKS:";
cin>>z;
r1.gettest(y,z);
cout< < endl< < endl< < "************ RESULT **************"< < endl;
r1.displayresult();
cout< < "**********************************"< < endl;
getch();

}
/************ OUTPUT ************
Enter Your Name:Lionel
Enter The Roll Number:44
ENTER COMPUTER PROGRAMMING MARKS:95
ENTER DRAWING MARKS:90


************ RESULT **************
The Name Of Student : Lionel
The Roll No. Is : 44
Marks In CP Is : 95
Marks In Drawing Is : 90
Total Of The Two : 185
**********************************
*/

21 comments:

priyanka said...

thanks lionel!!!!nice program.

richa said...

code is easily understandable really.

Unknown said...

hey thank u... example is good.. can easily understand..

MAYUR said...

good and esily understand this programme and plez data structure
in a stack and queue programm plez write

Unknown said...

after executing this program i got 20 error mostly syntax

Unknown said...

after executing this program i got 20 error mostly syntax

Anonymous said...

thanks dear sir, i m really graceful. Please help me about more c++ features like op overloading and virtual classes. i m a MCA student

P Divya Vijayaraghavan said...

THANK U SO MUCH,IT WAS VERY USEFUL TO ME...........

P Divya Vijayaraghavan said...

THANK U,THIS WAS VERY HELPFUL TO ME..........

sindhu said...

very good understandable program...

Anonymous said...

Thank u so much... its very understandable....

vj said...

thanku so much!easily understandable

Anonymous said...

thank you very much.codes r easily understable

chandan said...

nice program.
thank's
i'm loving it

chandan said...

nice program,

chandan said...

nice program.
thank's
i'm loving it

chandan said...

nice program.
thank's
i'm loving it

Varun singh said...

issy easy program nai milla tha kya smjhaney k liye?

Pehu said...

easily understand program, thank's.

Pehu said...

easily understand program, thank's.

Anonymous said...

not so good program

Your Ad Here