0% found this document useful (0 votes)
113 views15 pages

C++ Inheritance Project Report

This document is a micro project report submitted by three students for their diploma in computer engineering. It discusses implementing multilevel and hybrid inheritance in C++. The report includes an introduction, aims/benefits, methodology, outputs including code samples, and a conclusion on skills learned. It was certified by their project guide and department head.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
113 views15 pages

C++ Inheritance Project Report

This document is a micro project report submitted by three students for their diploma in computer engineering. It discusses implementing multilevel and hybrid inheritance in C++. The report includes an introduction, aims/benefits, methodology, outputs including code samples, and a conclusion on skills learned. It was certified by their project guide and department head.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

A

Micro Project Report On

“Implement multilevel and hybrid inheritance”


IN FULFILMENT OF DIPLOMA IN COMPUTER ENGINEERING OF

MSBTE MUMBAI

Submitted by:

1. Swayam.B. Khot (2326)


2. Mrunmayee.M. Kulkarni (2327)
3. Ganesh.S. Kumbhar (2328)

Program Name: Computer Engineering


Course Name: Object oriented programming using C++ (22316)
Subject Teacher: Mrs. P. P. Mahajan.

Department of Computer Engineering

Shree Swami Vivekanand Shikshan Sanstha's


Dr. BAPUJI SALUNKHE INSTITUTE OF ENGINEERING AND TECHNOLOGY

KOLHAPUR

Academic Year 2023 - 2024


Shree Swami Vivekanand Shikshan Sanstha's

Dr. Bapuji Salunkhe Institute of Engineering & Technology,


Kolhapur.

CERTIFICATE

This is to certify that the following students of Second Year Computer Engineering

1.Swayam Khot (2326)


2.Mrunmayee Kulkarni (2327)
3.Ganesh Kumbhar (2328)

have completed their Micro-Project work on " Implement multilevel and hybrid
inheritance ". This is in partial fulfillment of the requirements for the award of the
Diploma in Computer Engineering and submitted to the Computer Engineering
Department of Dr. Bapuji Salunkhe Institute of Engineering & Technology, Kolhapur
work carried out during a period of the academic Year 2023-2024 as prescribed the
curriculum of MSBTE.

Place:Kolhapur

Date:

Mrs. P. P. Mahajan Mr. S. A. Mujawar Prof. V. D. Bhirdi


Micro Project Guide Head of Department Principal
ACKNOWLEDGEMENT

It's our Pleasure to express sincere and heartiest thanks to ourMicro-Project


guide Mrs. P. P. Mahajan for their valuable guidance, encouragement and support for
the accomplishment of Micro-Project.

We are also really thankful to our Principal Prof. V. D. Bhirdi and the Head
of Department Mr. S. A. Mujawar for their constant encouragement and motivation for
the accomplishment of the Micro-Project by expressing their guidelines regarding
importance of Micro-Project in developing our career,

I am thankful to Co-workers of this Micro-Project for their valuable


contribution. We are thankful to all those peoples who directly or indirectly helped us
in completion of this Micro-project.

• Name of Students:
Swayam Khot (2326)
Mrunmayee Kulkarni (2327)
Ganesh Kumbhar (2328)
INDEX

Sr. No. Contents Page No.

1 Rationale 1

2 Aims/Benefits 1

3 Course Outcome Addressed 1

4 Literature Review 1

5 Actual Methodology Followed 1

6 Actual Resources Used 2

7 Outputs of the Micro-Project 2-9

8 Skill Developed / Learning outcome of this Micro-Project 10

9 Application of this Micro-Project 10


Title: Implement multilevel and hybrid inheritance
1.0 Rationale:
Multilevel inheritance involves creating a chain of classes where each class inherits from the
one above it. This helps to represent real-world relationships and hierarchies more accurately.
Hybrid inheritance, on the other hand, is a combination of multiple types of inheritance, like
multiple, multilevel, or hierarchical.

2.0 Aims

Study and implement multilevel and hybrid inheritance in C++ to understand their concepts.

• Benefits

1) Multilevel inheritance allows you to reuse code from multiple levels


2) Hybrid inheritance combines different forms of inheritance, offering greater flexibility in
modeling complex relationships between classes.

3.0 Course Outcomes Addressed


c) Implement Inheritance in C ++ program.

4.0 Literature Search:

Sr. Name of
Book Name Author
No Resource
Reference Dr. Rajendra
1. C++ Programming
Book kawale

2. Website https://www.khanacademy.org/ -

5.0 Actual Methodology Followed

1. Gathered Information:
Gathered all the possible information about internet and browsers from various resources like: -
1. Tutorials
2. Reference Links / Websites - https://www.khanacademy.org/
3. Reference books – C++ Programming

1
6.0 Actual Resource Used:

Sr. Name of
Specification
no. Resource

1. Operating System Window 10

2. Software Turbo C/C++

3. Computer system Intel Core i3-3240 CPU @ 3.40GHz

2
7.0 Output of the Micro-project:

➢ Multilevel Inheritance:
Multilevel Inheritance in C++ is the process of deriving a class from another derived class.
When one class inherits another class it is further inherited by another class. It is known as
multi-level inheritance.

i. Syntax:
class A // base class
{
...........
};
class B : access_specifier A // derived class
{
...........
};
class C : access_specifier B // derived from derived class B
{
...........
};

ii. Block Diagram of Multilevel Inheritance:

3
iii. Program:

//Multilevel Inheritance.
#include<iostream>
using namespace std;

class basic
{
public:
string name;
int empid;
string gender;
void BasicInfo()
{
cout << "Enter Your Name: ";
cin >> name;
cout << "Enter Your Employee ID: ";
cin >> empid;
cout << "Enter Your Gender: ";
cin >> gender;
}
};
class dept:public basic
{
public:
string deptname;
float Salary;
int year;
void DeptInfo()

{
cout << "Enter Your Department Name: ";
cin >> deptname;
cout << "Enter Salary: ";
cin >> Salary;
cout << "Enter Year of Experiance: ";
cin >> year;
}
};
class employee: public dept
{
public:
void EmployeeDetails(){
cout << "Enter employee's basic info: "<< endl;
BasicInfo();

4
cout << "Enter employee's department info: "<< endl;
DeptInfo();
}
void EmployeeInfo()
{
cout << "\n\n***** Basic Information of Employee *****"<< endl;
cout << "Name: " << name << endl;
cout << "Employee ID: " << empid << endl;
cout << "Gender: " << gender << endl << endl;
cout << "***** Department Information *****" << endl;
cout << "Department Name: " << deptname << endl;
cout << "Salary: " << Salary << endl;
cout << "Year of Experiance: " << year << endl;
}
};
int main()
{
employee emp;
emp.EmployeeDetails();
emp.EmployeeInfo();
return 0;
}

Output:
Enter employee's basic info:
Enter Your Name: Ganesh
Enter Your Employee ID: 1234
Enter Your Gender: Male

Enter employee's department info:


Enter Your Department Name: Sales
Enter Salary: 200000
Enter Year of Experiance: 4
***** Basic Information of Employee *****
Name: Ganesh
Employee ID: 1234
Gender: Male

***** Department Information *****


Department Name: Sales
Salary: 200000
Year of Experiance: 4

5
➢ Hybrid Inheritance:
Hybrid inheritance in C++ is a combination of multiple inheritance and hierarchical
inheritance. This means that a class can be derived from two or more classes, and one of the
parents can also be a derived class.
i. Syntax:
Class A
{
// block of statement(s)
};
Class B: public A // class B derived from a single class A – Single inheritance
{
// block of statement(s)
};
Class C
{
// block of statement(s)
};
Class D: public B, public C
{
// class D derived from two classes, class B and class C – Multiple inheritance
{
// block of statement(s)
};

ii. Block Diagram of Hybrid Inheritance:

6
iii. Program:
//Hybrid Inheritance
#include <iostream>
using namespace std;

class Student {
protected:
int rollno;
string name;

public:
void getdata() {
cout << “\n\n**Enter your personal details**\n” << endl;
cout << “Enter roll number: “;
cin >> rollno;
cout << “Enter name: “;
cin >> name;
}
void putdata() {
cout << “Roll number: “ << rollno << endl;
cout << “Name: “ << name << endl;
}
};
class Marks {
protected:
int m1, m2, m3;
public:
void getmarks() {
cout << “Enter marks for subject 1: “;
cin >> m1;
cout << “Enter marks for subject 2: “;
cin >> m2;
cout << “Enter marks for subject 3: “;
cin >> m3;
}
void putmarks() {
cout << “Marks for subject 1: “ << m1 << endl;

7
cout << “Marks for subject 2: “ << m2 << endl;
cout << “Marks for subject 3: “ << m3 << endl;
cout << “Average of Marks:”<<(m1+m2+m3)/3 << endl;
}
};

class Sports : public Student {


public:
int score;
string sport;

void getscore() {
cout << “Enter your favorite sport :” ;
cin >>sport;
cout << “Enter score in sports: “;
cin >> score;
}
void putscore() {
cout << “Score in sports: “<<sport <<endl;
cout << “Score in sports: “ << score << endl;
}
};

class Result : public Marks, public Sports {


public:
void display() {

cout << “\n******Student details:******” << endl;


putdata();

Cout << “\n*****Marks details:*****” << endl;


putmarks();
cout << “\n*****Sports details:*****” << endl;
putscore();
}
};
int main() {
Result r;
r.getdata();
r.getmarks();

8
r.getscore();
r.display();
return 0;
}

Output:
**Enter your personal details**

Enter roll number: 1234


Enter name: Ganesh
Enter marks for subject 1: 98
Enter marks for subject 2: 97
Enter marks for subject 3: 96

Enter your favorite sport :Cricket


Enter score in sports: 5

******Student details:******
Roll number: 1234
Name: Ganesh

*****Marks details:*****
Marks for subject 1: 98
Marks for subject 2: 97
Marks for subject 3: 96
Average of Marks:97

*****Sports details:*****
Score in sports: Cricket
Score in sports: 5

9
8.0 Skill Developed / Learning outcome of this Micro-Project:
➢ Understanding class hierarchies: You'll learn how to create complex class
relationships. Code organization: Skills for structuring code in a hierarchy.
➢ Multilevel Inheritance: Understanding how a class can inherit from a class which, in
turn, inherits from another class, creating a multi-level hierarchy.
➢ Hybrid Inheritance: Comprehending the combination of different types of inheritance
(e.g., multiple, multilevel) to build complex class structures.

9.0 Applications of this Micro-Project:


➢ A game engine could use multilevel inheritance to model the different types of objects
in the game, such as players, enemies, and objects.
➢ A word processing program could use hybrid inheritance to model the different types
of documents that can be created, such as letters, reports, and presentations.

Subject Teacher
Mrs. P. P. Mahajan

You might also like