MULTILEVEL INHERITANCE
AIM:
A program to illustrate multilevel inheritance. we have three classes, student, test and result. Here class student is the base class. And the class test is derived from the base class student. And the another class result is derived from the class test.
ALGORITHM:
• Start the process
• Invoke the base class student
• Invoke the derived class test which in inherited by the class student
• Invoke the derived class result which in inherited by the class test
• Create an object student1 for the result class
• Call student1.getno(),assign the value of rno in student class
• Call student1.getmarks(),assign the marks in test class
• Call student1.display(),for displaying the result
• Stop the process
PROGRAM
#include#include class student { protected: int rno; public: void getno(int); void putno(void); }; void student::getno(int a) { rno=a; } void student ::putno() { cout<<"rollno="<
Description :
This is the one stop educational site for all Electronic and Computer students. If you want to learn something new then we are here to help. We work on Microcontroller projects, Basic Electronics, Digital electronics, Computer projects and also in basic c/c++ programs.
#Home #Sitemap #Submit #Terms of Use
Copyright©2011 electrofriends.com All Rights Reserved
Contact:info@electrofriends.com | Powered by Dhyeya
ok …youn arec good
please sir write full program on the give above of mulipal inheritance and send krishango16@gmail.com
/********* IMPLEMENTATION OF MULTILEVEL INHERITANCE *********/
#include
#include
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< >n;
cout< >x;
result r1;
r1.getdata(x,n);
cout< >y;
cout< >z;
r1.gettest(y,z);
cout< < endl< < endl< < "************ RESULT **************"< < endl;
r1.displayresult();
cout< < "**********************************"< < endl;
getch();
}
A.BHARAJA IS A INDIAN
/********* IMPLEMENTATION OF MULTILEVEL INHERITANCE *********/
#include
#include
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< >n;
cout< >x;
result r1;
r1.getdata(x,n);
cout< >y;
cout< >z;
r1.gettest(y,z);
cout< < endl< < endl< < "************ RESULT **************"< < endl;
r1.displayresult();
cout< < "**********************************"< < endl;
getch();
}
atala badha hard program n hoy…..example tarikhe easy program apvana hoy…..
content should be in elaborate condition,it s not sufficient to understand.