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

Inheritance in

C++

Dr. Munesh
Singh
Inheritance in C++

Dr. Munesh Singh

Indian Institute of Information Technology


Design and Manufacturing,
Kancheepuram
Chennai-600127

January 19, 2019


Understand the need of Inheritance

Inheritance in
C++

Dr. Munesh
Singh

Class is used to describe properties and behavior of an


object.
Property names and values
Behavior means actions
Let us assume that we want to represent a car.
Car

Inheritance in
C++

Dr. Munesh
Singh
Sport Car

Inheritance in
C++

Dr. Munesh
Singh
Inheritance

Inheritance in
C++

Dr. Munesh
Singh

It is a process of inheriting properties and behavior of


exising class into a new class.
Existing class=old class=Parent class=Base class
New class= Child class=Derived Class
Syntax

Inheritance in
C++

Dr. Munesh
Singh
Example

Inheritance in
C++

Dr. Munesh
Singh
Types of Inheritance

Inheritance in
C++

Dr. Munesh
Singh

Single Inheritance
Multilevel Inheritance.
Multiple Inheritance
Hierarchical Inheritance
Hybrid Inheritance
Single Inheritance

Inheritance in
C++

Dr. Munesh
Singh
Multilevel Inheritance

Inheritance in
C++

Dr. Munesh
Singh
Multiple Inheritance

Inheritance in
C++

Dr. Munesh
Singh
Hierarchical Inheritance

Inheritance in
C++

Dr. Munesh
Singh
Visibility Modes

Inheritance in
C++ Private
Dr. Munesh
Singh Protected
Public
Types of users of a class
User 1 will create Object of your class
User 2 will derived class from your class
Availability vs Accessibility
Example of Inheritance

Inheritance in
C++

Dr. Munesh
Singh

You might also like