Inheritance
Inheritance
MIT POLYTECHNIC
ROTEGAON.
2024-2025
A PROJECT REPORT ON
SUBMITED BY:
Page 1 of 16
Computer Engineering object-oriented programming using c++
CERTIFICATE:
§ Roll No: 09
§ Roll No: 10
§ Roll No: 64
TABLE OF CONTENTS
Page 2 of 16
Computer Engineering object-oriented programming using c++
2 Introduction 5
3 Concepts 6
4 Program 7
6 Conclusion 14
7 Acknowledgement 15
8 Reference 16
Page 3 of 16
Computer Engineering object-oriented programming using c++
Page 4 of 16
COMPUTER ENGINEERING object-oriented programming using c++
Introduction
Multiple Inheritance
Multilevel Inheritance
Page 5 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Concepts
1.Multiple Inheritance
In Multiple inheritance, a single derived class can inherit property
from more than one base class. For example, as explained below,
class Derived inherits property from both Class Base1 and Class
Base2.
Syntax:
Page 6 of 17
COMPUTER ENGINEERING object-oriented programming using c++
• Step 3: Declare and define the function get () to get the student
details.
• Step 5: Declare and define the function getsm () to read the sports
mark.
• Step 6: Create the class statement derived from student and sports.
• Step 7: Declare and define the function display () to find out the
Page 7 of 17
COMPUTER ENGINEERING object-oriented programming using c++
• Step 8: Declare the derived class object, call the functions get (),
2. Multilevel Inheritance
In multilevel inheritance, the derived class inherits property from another derived
class. For example, as explained below, class Derived1 inherits property from class
Base and class Derived2 inherits property from class Derived1.
Syntax:
Page 8 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Page 9 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Program
Multiple Inheritance Program
Page 10 of 17
COMPUTER ENGINEERING object-oriented programming using c++
{
int result;
result= a+b+c+d+e+f+g;
cout<<" Sum of all the values is: "<<result<< endl;
}
};
int main()
{
Value_4 v;
v.sum();
}
OUTPUT
Page 11 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Program
Multilevel Inheritance
Page 12 of 17
COMPUTER ENGINEERING object-oriented programming using c++
{
R r;
r.display();
r.display1();
return 0;
}
Output:
Page 13 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Conclusion
Multiple inheritance
Here, we have seen the concept of multiple inheritance which can take place
through the concept of variables and methods using the C++ programming
language. We even displayed the error output in case of accessing the property
of the base class without being inherited by the derived class. Keep practicing
with different access modifies (public, private and protected) and understand
the workflow for the same.
Multi-level inheritance
Page 14 of 17
COMPUTER ENGINEERING object-oriented programming using c++
Acknowledgement:
We take this opportunity to express sincere thanks to our project guide.
Ms. Lavangare.V.M Under whose guidance our project is done.
We also thanks to all the Computer department teachers for their
valuable guidance, and timely suggestions without which we
could not complete this project work.
Only because of our staff inspiration and instructions we
could achieve satisfactory completion of project work.
Last but not least, we wish to thanks all of those who have helped us
Page 15 of 17
Computer Engineering object-oriented programming using c++
Reference
➢ Internet link used as reference: