Computer Engineering Object-Oriented Programming Using C++
Computer Engineering Object-Oriented Programming Using C++
Computer Engineering Object-Oriented Programming Using C++
2020-2021
A PROJECT REPORT ON
SUBMITED BY:
(Computer Dept.)
Page 1 of 16
Computer Engineering object-oriented programming using c++
CERTIFICATE:
§ Roll No: 16
§ Roll No: 17
§ Roll No: 18
Page 2 of 16
Computer Engineering object-oriented programming using c++
TABLE OF CONTENTS
2 Action plan 5
3 Introduction 6
4 Concepts 7
5 Program 10,12
7 Conclusion 14
8 15
Acknowledgement
9 Reference 16
Page 3 of 16
Computer Engineering object-oriented programming using c++
Page 4 of 16
Computer Engineering object-oriented programming using c++
ACTION PLAN
Page 5 of 16
COMPUTER ENGINEERING object-oriented programming using c++
Introduction
Multiple Inheritance
Inheritance is an object-oriented property concept where a class can
access the properties and methods of the other class. The class which
attains the qualities of the other class is called the derived/child class.
The class which gives the right to giving its properties to other classes
is called base/parent class.
Multilevel Inheritance
Page 6 of 16
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:
//body of Derived class which inherit property from more than one
base class that is Base1 & Base2
};
Page 7 of 16
COMPUTER ENGINEERING object-oriented programming using c++
• Step 3: Declare and define the function get () to get the student
details.
sports mark.
sports.
• Step 7: Declare and define the function display () to find out the
• Step 8: Declare the derived class object, call the functions get (),
Page 8 of 16
COMPUTER ENGINEERING object-oriented programming using c++
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:
class
{ Derived1: access_mode Base
//body of Derived1 class which inherit property from base class
};
Class Derived2: access_mode Derived1
{
//body of Derived2 class which inherit property from Derived1 class
};
Page 9 of 16
COMPUTER ENGINEERING object-oriented programming using c++
Program
#include <iostream>
using namespace std;
class Value_1
{
public:
int a = 10;
int b = 20;
};
class Value_2
{
public:
int c = 30;
int d = 40;
};
class Value_3
{
public:
int e = 50;
int f = 60;
int g = 70;
};
class Value_4: public Value_1,public Value_2,public Value_3
{
public:
void sum()
Page 10 of 16
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 16
COMPUTER ENGINEERING object-oriented programming using c++
Program
Multilevel Inheritance
#include <iostream>
using namespace std;
class P
{
public:
void display ()
{
cout<<"All contents of Base Class";
}
};
class Q: public P
{
public:
void display1()
{
cout<<"\nall content of class Q.";
}
};
class R: public Q
{
public:
void display2()
{
cout<<"All contents if class R.";
}
};
int main ()
Page 12 of 16
COMPUTER ENGINEERING object-oriented programming using c++
{
R r;
r.display();
r.display1();
return 0;
}
Output:
Page 13 of 16
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 16
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 16
Computer Engineering object-oriented programming using c++
Reference
➢ Internet link used as reference:
Page 16 of 16