SlideShare a Scribd company logo
By Sonali Gholve
Base
Derived1 Derived2
Parent
Child
Grand
Parent
Prent
Child
 The method by which we can derive a new
class from an old called Inheritance or
derivation.
 Old class- Base class
 New class- Derived class/ subclass
Parent/Old/Base
Child/new/derived
 Single Inheritance
 Multilevel Inheritance
 Multiple Inheritance
 Hierarchical Inheritance
 Hybrid Inheritance
 Multipath Inheritance
 Reusability- use the function/data in derived
class
 Reliability- Derived class is used or adapt the
feature from the base class
 Save time and memory
 Enhancement
 Classification
 Industry used
Syntax:
class base
{
class body;
members of the class base;
};
class derived
:visibility_mode base
{
class body;
members of the class
derived;
};
example:
class shapes
{
char color;
void show();
};
class square :public shapes
{
int side;
void area();
};
 If we declare members in private visibility
mode, then that used is only within a self
class and not other class.
 If we declare members in protected
visibility mode, then that used is only within a
self class and derived class not other class.
 If we declare members in public visibility
mode, then that used for all function, which
declared in the program.
Parent
Child
• Only one base/Parent class and only
one derived/child class
• If a single class is derived from one
base class then it is called single
inheritance.
• Child has own functionality, which is
differ than parent class.
#include <iostream>
using namespace std;
class parent //single base class
{
public: int x;
void getdata()
{
cout << "Enter the value of x = ";
cin >> x;
}
};
class child : public parent //single
derived class
{
private: int y;
public: void readdata()
{
cout << "Enter the value of y = ";
cin >> y;
}
void product()
{
cout << "Product = " << x * y;
} };
int main()
{
child a; //object of derived class
a.getdata();
a.readdata();
a.product();
return 0; }
 If a class(ABC) is derived from another
derived class(XYZ) then it is called multilevel
inheritance.
 So in C++ multilevel inheritance, a class has
more than one parent class.
 XYZ class is also known as
intermediate base class.
Grand
Parent
XYZ
ABC
#include <iostream>
using namespace std;
class grandparent //single base class
{
public: int x;
void getdata()
{
cout << "enter the value of x = ";
cin >> x;
}
};
class parent : public grandparent // derived class
{
public: int y;
void readdata()
{
cout << "enter the value of y = ";
cin >> y;
}
};
class child : public parent
// derived from class parent
{
private: int z;
public: void intdata()
{
cout << "nenter value of z= ";
cin >> z; }
void product()
{
cout << "nproduct= " << x * y * z;
} };
int main()
{
child a; //object of clild class
a.getdata();
a.readdata();
a.intdata();
a.product();
return 0; }
Inheritance in c++theory

More Related Content

What's hot (20)

PPTX
OOP Introduction with java programming language
Md.Al-imran Roton
 
PPTX
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
PPTX
Multiple inheritance in java3 (1).pptx
RkGupta83
 
PPTX
Templates in c++
Mayank Bhatt
 
PPT
Inheritance C#
Raghuveer Guthikonda
 
PPTX
Hash table in java
siriindian
 
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PDF
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
PPTX
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
PPTX
Virtual Functions | Polymorphism | OOP
shubham ghimire
 
PPTX
07. Virtual Functions
Haresh Jaiswal
 
PPTX
Polymorphism in C++
Rabin BK
 
PDF
Applets
Prabhakaran V M
 
PPTX
Object oriented programming
Amit Soni (CTFL)
 
PPTX
Static Data Members and Member Functions
MOHIT AGARWAL
 
PPSX
Inheritance
Selvin Josy Bai Somu
 
PPTX
Main method in java
Hitesh Kumar
 
PPTX
Basic Graphics in Java
Prakash Kumar
 
PPTX
Inheritance In C++ (Object Oriented Programming)
Gajendra Singh Thakur
 
PPTX
Object Oriented Programing JAVA presentaion
Pritom Chaki
 
OOP Introduction with java programming language
Md.Al-imran Roton
 
WHAT IS ABSTRACTION IN JAVA
sivasundari6
 
Multiple inheritance in java3 (1).pptx
RkGupta83
 
Templates in c++
Mayank Bhatt
 
Inheritance C#
Raghuveer Guthikonda
 
Hash table in java
siriindian
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Virtual Functions | Polymorphism | OOP
shubham ghimire
 
07. Virtual Functions
Haresh Jaiswal
 
Polymorphism in C++
Rabin BK
 
Object oriented programming
Amit Soni (CTFL)
 
Static Data Members and Member Functions
MOHIT AGARWAL
 
Main method in java
Hitesh Kumar
 
Basic Graphics in Java
Prakash Kumar
 
Inheritance In C++ (Object Oriented Programming)
Gajendra Singh Thakur
 
Object Oriented Programing JAVA presentaion
Pritom Chaki
 

Similar to Inheritance in c++theory (20)

PPTX
Inheritance
SangeethaSasi1
 
PPTX
00ps inheritace using c++
sushamaGavarskar1
 
PPTX
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
PDF
Chapter 6 and inheritance OOP C++ tu ioe
EZERR1
 
PPTX
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
PDF
Inheritance
Pranali Chaudhari
 
PPT
Inheritance OOP Concept in C++.
MASQ Technologies
 
PPTX
Access controlaspecifier and visibilty modes
Vinay Kumar
 
PPTX
Inheritance
Misbah Aazmi
 
DOCX
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
PPTX
Inheritance.pptx
RutujaTandalwade
 
PPT
Inheritance
poonam.rwalia
 
PPT
02-OOP with Java.ppt
EmanAsem4
 
PPT
025466482929 -OOP with Java Development Kit.ppt
DakshinaPahan
 
PPTX
inheritance
krishna partiwala
 
PDF
OOP Assign No.03(AP).pdf
Anant240318
 
PPTX
OOPS IN C++
Amritsinghmehra
 
PPT
Java oops PPT
kishu0005
 
PPTX
Inheritance (with classifications)
Redwan Islam
 
PPTX
Chap-3 Inheritance.pptx
chetanpatilcp783
 
Inheritance
SangeethaSasi1
 
00ps inheritace using c++
sushamaGavarskar1
 
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
Chapter 6 and inheritance OOP C++ tu ioe
EZERR1
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
Inheritance
Pranali Chaudhari
 
Inheritance OOP Concept in C++.
MASQ Technologies
 
Access controlaspecifier and visibilty modes
Vinay Kumar
 
Inheritance
Misbah Aazmi
 
oop database doc for studevsgdy fdsyn hdf
itxminahil29
 
Inheritance.pptx
RutujaTandalwade
 
Inheritance
poonam.rwalia
 
02-OOP with Java.ppt
EmanAsem4
 
025466482929 -OOP with Java Development Kit.ppt
DakshinaPahan
 
inheritance
krishna partiwala
 
OOP Assign No.03(AP).pdf
Anant240318
 
OOPS IN C++
Amritsinghmehra
 
Java oops PPT
kishu0005
 
Inheritance (with classifications)
Redwan Islam
 
Chap-3 Inheritance.pptx
chetanpatilcp783
 
Ad

More from ProfSonaliGholveDoif (6)

PPTX
Searching in Artificial Intelligence for UG
ProfSonaliGholveDoif
 
PPTX
Artificial Intelligence Basics part 1 for UG students
ProfSonaliGholveDoif
 
PPTX
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
PPTX
File handling in c++
ProfSonaliGholveDoif
 
PPTX
Macro and Preprocessor in c programming
ProfSonaliGholveDoif
 
PPTX
String predefined functions in C programming
ProfSonaliGholveDoif
 
Searching in Artificial Intelligence for UG
ProfSonaliGholveDoif
 
Artificial Intelligence Basics part 1 for UG students
ProfSonaliGholveDoif
 
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
File handling in c++
ProfSonaliGholveDoif
 
Macro and Preprocessor in c programming
ProfSonaliGholveDoif
 
String predefined functions in C programming
ProfSonaliGholveDoif
 
Ad

Recently uploaded (20)

PPTX
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
 
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
PDF
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
PDF
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Wondershare Filmora Crack Free Download 2025
josanj305
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
PDF
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
FME in Overdrive: Unleashing the Power of Parallel Processing
Safe Software
 
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Securing Model Context Protocol with Keycloak: AuthN/AuthZ for MCP Servers
Hitachi, Ltd. OSS Solution Center.
 
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
 
Darley - FIRST Copenhagen Lightning Talk (2025-06-26) Epochalypse 2038 - Time...
treyka
 
Next Generation AI: Anticipatory Intelligence, Forecasting Inflection Points ...
dleka294658677
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Wondershare Filmora Crack Free Download 2025
josanj305
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Practical Applications of AI in Local Government
OnBoard
 
TrustArc Webinar - Navigating APAC Data Privacy Laws: Compliance & Challenges
TrustArc
 
Sound the Alarm: Detection and Response
VICTOR MAESTRE RAMIREZ
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
🚀 Let’s Build Our First Slack Workflow! 🔧.pdf
SanjeetMishra29
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
FME in Overdrive: Unleashing the Power of Parallel Processing
Safe Software
 
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 

Inheritance in c++theory

  • 1. By Sonali Gholve Base Derived1 Derived2 Parent Child Grand Parent Prent Child
  • 2.  The method by which we can derive a new class from an old called Inheritance or derivation.  Old class- Base class  New class- Derived class/ subclass Parent/Old/Base Child/new/derived
  • 3.  Single Inheritance  Multilevel Inheritance  Multiple Inheritance  Hierarchical Inheritance  Hybrid Inheritance  Multipath Inheritance
  • 4.  Reusability- use the function/data in derived class  Reliability- Derived class is used or adapt the feature from the base class  Save time and memory  Enhancement  Classification  Industry used
  • 5. Syntax: class base { class body; members of the class base; }; class derived :visibility_mode base { class body; members of the class derived; }; example: class shapes { char color; void show(); }; class square :public shapes { int side; void area(); };
  • 6.  If we declare members in private visibility mode, then that used is only within a self class and not other class.  If we declare members in protected visibility mode, then that used is only within a self class and derived class not other class.  If we declare members in public visibility mode, then that used for all function, which declared in the program.
  • 7. Parent Child • Only one base/Parent class and only one derived/child class • If a single class is derived from one base class then it is called single inheritance. • Child has own functionality, which is differ than parent class.
  • 8. #include <iostream> using namespace std; class parent //single base class { public: int x; void getdata() { cout << "Enter the value of x = "; cin >> x; } }; class child : public parent //single derived class { private: int y; public: void readdata() { cout << "Enter the value of y = "; cin >> y; } void product() { cout << "Product = " << x * y; } }; int main() { child a; //object of derived class a.getdata(); a.readdata(); a.product(); return 0; }
  • 9.  If a class(ABC) is derived from another derived class(XYZ) then it is called multilevel inheritance.  So in C++ multilevel inheritance, a class has more than one parent class.  XYZ class is also known as intermediate base class. Grand Parent XYZ ABC
  • 10. #include <iostream> using namespace std; class grandparent //single base class { public: int x; void getdata() { cout << "enter the value of x = "; cin >> x; } }; class parent : public grandparent // derived class { public: int y; void readdata() { cout << "enter the value of y = "; cin >> y; } }; class child : public parent // derived from class parent { private: int z; public: void intdata() { cout << "nenter value of z= "; cin >> z; } void product() { cout << "nproduct= " << x * y * z; } }; int main() { child a; //object of clild class a.getdata(); a.readdata(); a.intdata(); a.product(); return 0; }