TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Multi-level inheritance in OOP
Barkha Gupta
Jan 24
2016
Code
2.4
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
* /program to illutrate multilevel inheritance./ *
#include < iostream > using namespace std;
class
student
{
protected
:
int
roll;
public
:
void
getdata(
int
);
void
putdata(
void
);
};
void
student::getdata(
int
a)
{
roll = a;
}
void
student::putdata()
{
cout <<
"\nrollno:"
<< roll;
}
class
test:
public
student
{
protected
:
float
sub1;
float
sub2;
public
:
void
get(
float
,
float
);
void
put(
void
);
};
void
test::get(
float
x,
float
y)
{
sub1 = x;
sub2 = y;
}
void
test::put()
{
cout <<
"\n'c' marks:"
<< sub1;
cout <<
"\n'c++' marks:"
<< sub2;
}
class
result:
public
test
{
float
total;
public
:
void
display(
void
);
};
void
result::display(
void
)
{
total = sub1 + sub2;
putdata();
put();
cout <<
"\ntotal="
<< total;
}
int
main()
{
result stu;
stu.getdata(150);
stu.get(78.0, 65.8);
stu.display();
return
0;
}
Inheritence
C++
OOPS