Computer Engineering Object-Oriented Programming Using C++

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Computer Engineering object-oriented programming using c++

Maharashtra State Board of Technical Education,


Mumbai

Vidyavardhini Charitable Trust’s

Abhaysinhraje Bhonsle Institute of Technology


Shahunagar - Shendre, Satara.

2020-2021

A PROJECT REPORT ON

Project Name: “MULTIPLE INHERITANCE AND MULTILEVEL


INHERITANCE PROGRAM WITH OUTPUT”

SUBMITED BY:

1) PATIL SHUBHAM NANASO (16)


2) PAWAR TEJAS GOPAL (17)
3) SAWALE KARAN YUVRAJ (18)

UNDER THE GUIDANCE OF: Ms. Lavangare.V.M

Sub Teacher Name: Ms. Lavangare.V.M

(Computer Dept.)

Page 1 of 16
Computer Engineering object-oriented programming using c++

CERTIFICATE:

This is to certify that:

§ Roll No: 16
§ Roll No: 17
§ Roll No: 18

Diploma in Computer Engineering, has satisfactorily completed the project


work under mini project report on, Project Name: “MULTIPLE
INHERITANCE AND MULTILEVEL INHERITANCE PROGRAM
WITH OUTPUT” under my guidance and supervision, this is part of partial
fulfilment of the requirement for submission of Maharashtra State Board of
Technical Education, Mumbai during Semester third of Academic
year 2020-2021.

GUIDE HOD PRINCIPAL


Ms. Lavangare.V.M Ms. Nikam.R.A. Mr. Dhumal.S.U.
Computer Dept. Computer Engineering A.B.I.T.(Poly),
Dept. Satara
A.B.I.T(Poly), Satara A.B.I.T.(Poly), Satara

Page 2 of 16
Computer Engineering object-oriented programming using c++

TABLE OF CONTENTS

SR .NO INDEX PAGE NO

1 Aim of the Microproject 4

2 Action plan 5

3 Introduction 6

4 Concepts 7

5 Program 10,12

6 Program output 11,13

7 Conclusion 14

8 15
Acknowledgement

9 Reference 16

Page 3 of 16
Computer Engineering object-oriented programming using c++

Aim of the Microproject

Object-oriented programming System (OOPs) is a programming


paradigm based on the concept of “objects” that contain data and
methods. The primary purpose of object-oriented programming is to
increase the flexibility and maintainability of programs. Object
oriented programming brings together data and its
behavior(methods) in a single location(object) makes it easier to
understand how a program works. We will cover each and every
feature of OOPs in detail so that you won’t face any difficulty
understanding OOPs Concepts.

Page 4 of 16
Computer Engineering object-oriented programming using c++

ACTION PLAN

Action Details of activity Start Date Finish Responsible


Plan: Date Team
Sr. No member
1 Selected the topic for 30-11-20 10-12-20 Tejas
micro-project
2 We organized things 10-12-20 20-12-20 Karan
required for our project

3 We browsed the 20-12-20 25-12-20 Shubham


internet for
information and raw
data
4 We attended extra 25-12-21 05-01-21 Karan
lectures for our project
topic
5 We made 10-01-21 15-01-21 Tejas
points/notes on the
information we
collected
6 We created a word 15-01-21 20-01-21 Shubham
document with help
of our teacher
7 We made corrections 20-01-21 25-01-21 Karan
by discussing with
our teacher
8 We also created a PDF 25-01-21 30-01-21 Shubham
document to
make a hard copy of the
report

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.

In the concept of Multiple Inheritance, there are multiple base classes


and a child class. The derived class can attain its qualities from all the
base classes. Let us move further in understanding the concept of
Multiple Inheritance in C++ programming language.

Multilevel Inheritance

Inheritance is a property wherein an object of one class possesses the


properties of another class and can further inherit the properties to
other classes. Such type of parent-child relationship between class
frames to be an inheritance. Multilevel is a kind of inheritance where
a base or child class has more than one parent classes and it can be
extended to any level. Therefore, like other inheritance features
like hierarchical inheritance and multiple inheritances, we can
conclude that those base classes who have more than one parent class
been called Multilevel inheritance in C++.

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:

class Derived: access_mode Base1, access_mode Base2

//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++

Multiple Inheritance Algorithm

• Step 1: Start the program.

• Step 2: Declare the base class student.

• Step 3: Declare and define the function get () to get the student

details.

• Step 4: Declare the other class sports.

• 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

total and average.

• Step 8: Declare the derived class object, call the functions get (),

getsm () and display ().

• Step 9: Stop the program.

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

Multiple Inheritance 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

Unlike other inheritance multi-level inheritance has a special feature that it


can be extended to any level of inheritance besides a condition that it depends
on the requirements of the object and the class. Also, a base class can have
more than one parent class. This situation can even arise in the real world
which can be overcome using 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:

Multiple Inheritance in C++ | How Multiple Inheritance Works in C++? (educba.com)

Page 16 of 16

You might also like