/********* 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
**********************************
*/
Sunday, June 1, 2008
Subscribe to:
Post Comments (Atom)
21 comments:
thanks lionel!!!!nice program.
code is easily understandable really.
hey thank u... example is good.. can easily understand..
good and esily understand this programme and plez data structure
in a stack and queue programm plez write
after executing this program i got 20 error mostly syntax
after executing this program i got 20 error mostly syntax
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
THANK U SO MUCH,IT WAS VERY USEFUL TO ME...........
THANK U,THIS WAS VERY HELPFUL TO ME..........
very good understandable program...
Thank u so much... its very understandable....
thanku so much!easily understandable
thank you very much.codes r easily understable
nice program.
thank's
i'm loving it
nice program,
nice program.
thank's
i'm loving it
nice program.
thank's
i'm loving it
issy easy program nai milla tha kya smjhaney k liye?
easily understand program, thank's.
easily understand program, thank's.
not so good program
Post a Comment