SlideShare a Scribd company logo
JUNAIDVK
junaidvkomy@gmail.com
www.facebook.com/junaid.omy
twitter.com/junaid.omy
in.linkedin.com/in/junaidvkomy
9745991390
INHERITANCE
CONTENTS
• CLASS
BASE CLASS
DERIVED CLASS
• OBJECT
• INHERITANCE
SINGLE INHERITANCE
MULTIPLE INHERITANCE
HIERARCHICAL INHERITANCE
MULTILEVEL INHERITANCE
HYBRID INHERITANS(Virtual
Inheritance)
CLASS
• Class is the base design of objects
means expanded concept of a data,
that can hold both data and functions.
• No memory is allocated when class is
created.
• It is a user defined data type.
Example : A car is consider
as a class
Methods : Engine, wheels,
steering.
Properties : company,
model, colour,
speed, etc….
BASE CLASS
• The class from which the subclass is
derived is called a superclass (also a
base class or a parent class).
DERIVED CLASS
• A class that is derived from another
class is called a subclass (also a derived
class, extended class, or child class).
OBJECT
• Object is the instance of class, means
identifiable entity with some
characteristics and behaviour.
• Memory allocated when only an
object is created.
EXAMPLE PROGRAM :
#include <iostream>
using namespace std;
class person
{
public:
string name;
int number;
};
int main()
{
person obj;
cout<<"Enter the Name :";
cin>>obj.name;
cout<<"Enter the Number :";
cin>>obj.number;
cout << obj.name<< obj.number;
}
Output :
Enter the name : baabtra
Enter the number:123
baabtra123
INHERITANCE
 Deriving new class from existing class.
 Object of one class contains the
property of another class.
 Reusability.
 We can add features to an
existing class without modifying it.
TYPES OF INHERITANCE
• Single Inheritance
• Hierarchical Inheritance
• Multi Level Inheritance
• Hybrid Inheritance
• Multiple Inheritance
SINGLE INHERITANCE
• One derived class inherits
from only one base class
• Most simplest form of
Inheritance.
EXAMPLE
#include<iostream>
using namespace std;
class father
{
public:
string name;
int age,pincode;
};
class child:public father
{
public:
string school;
int standard;
};
main()
{
father obj1;
child obj2;
cout<<"enter the name of father:";
cin>>obj1.name;
cout<<"enter the age of father:";
cin>>obj1.age;
cout<<"enter the pincode of father:";
cin>>obj1.pincode;
cout<<"-------------DETAIL OF CHILD--------------n";
cout<<"enter the name of child:";
cin>>obj2.name;
cout<<"enter the age of child:";
cin>>obj2.age;
cout<<"enter the pincode of child:";
cin>>obj2.pincode;
cout<<"enter the school name of child:";
cin>>obj2.school;
cout<<"enter the standard of child:";
cin>>obj2.standard;
}
HEIRARCHICAL INHERITANCE
• More than one derived
classes is derived from
common base class.
EXAMPLE
#include<iostream>
using namespace std;
class user
{
public:
string name,place;
int age;
};
class student:public user
{
public:
int rollno,classs,mark1,mark2;
};
class teacher:public user
{
public:
string department;
int teacher_id,salary;
};
main()
{
user obj;
student obj1;
teacher obj2;
cout<<"-----------------STUDENT-------------n";
cout<<"enter the name:";
cin>>obj1.name;
cout<<"enter the age:";
cin>>obj1.age;
cout<<"enter the place:";
cin>>obj1.place;
cout<<"enter the rollno:";
cin>>obj1.rollno;
cout<<"enter the class:";
cin>>obj1.classs;
cout<<"enter the mark1:";
cin>>obj1.mark1;
cout<<"enter the mark2:";
cin>>obj1.mark2;
cout<<"---------------TEACHER---------------n";
cout<<"enter the name:";
cin>>obj2.name;
cout<<"enter the age:";
cin>>obj2.age;
cout<<"enter the place:";
cin>>obj2.place;
cout<<"enter the id:";
cin>>obj2.teacher_id;
cout<<"enter the salary:";
cin>>obj2.salary;
cout<<"enter the department:";
cin>>obj2.department;
}
MULTI LEVEL INHERITANCE
• Derived class is derived
from another derived class.
EXAMPLE
#include<iostream>
using namespace std;
class grandparent
{
public:
void gshow()
{
cout<<"intelligent";
}
};
class parent:public grandparent
{
public:
void pshow()
{
cout<<"nhandsom";
}
};
class child:public parent
{
public:
void cshow()
{
cout<<"nobedience";
}
};
main()
{
grandparent obj1;
parent obj2;
child obj3;
cout<<"QUALITY OF GRANDPAn";
obj1.gshow();
cout<<"nQUALITIES OF FATHERn";
obj2.gshow();
obj2.pshow();
cout<<"nQUALITIES OF CHILDn";
obj3.gshow();
obj3.pshow();
obj3.cshow();
}
HYBRID INHERITANCE
• Combination of single
Inheritance , hierarchical
inheritance and
multi level inheritance.
EXAMPLE
#include<iostream>
using namespace std;
class grandparent
{
public:void gshow()
{
cout<<"nintelligent";
}
};
class parent:public grandparent
{
public:
void pshow()
{
cout<<"neducated";
}
};
class son:public parent
{
public:
void sshow()
{
cout<<"nobedience";
}
};
class daugter:public parent
{
public:
void dshow()
{
cout<<"nbeautiful";
}
};
main()
{
grandparent gobj;
parent pobj;
son sobj;
daugter dobj;
cout<<"QUALITY OF GRANDPA";
gobj.gshow();
cout<<"nQUALITY OF PARENT";
pobj.gshow();
pobj.pshow();
cout<<"nQUALITIES OF SON";
sobj.sshow();
sobj.pshow();
sobj.gshow();
cout<<"nQUALITIES OF DAUGHTER";
dobj.dshow();
dobj.pshow();
dobj.gshow();
}
MULTIPLE INHERITANCE
• Derived class is derived
from more than one
base class.
EXAMPLE
#include<iostream>
using namespace std;
class father
{
public:
void fshow()
{
cout<<"discipline";
}
};
class mother
{
public:
void mshow()
{
cout<<"nopen minded";
}
};
class child:public father,public mother
{
public:
void cshow()
{
cout<<"nintelligent";
}
};
main()
{
father obj1;
mother obj2;
child obj3;
cout<<"QUALITY OF FATHERn";
obj1.fshow();
cout<<"n";
cout<<"nQUALITY OF MOTHER";
obj2.mshow();
cout<<"n";
cout<<"nQUALITIES OF CHILDn";
obj3.fshow();
obj3.mshow();
obj3.cshow();
}
Disclaimer: This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
Follow us @ twitter.com/baabtra
Like us @ facebook.com/baabtra
Subscribe to us @ youtube.com/baabtra
Become a follower @ slideshare.net/BaabtraMentoringPartner
Connect to us @ in.linkedin.com/in/baabtra
Give a feedback @ massbaab.com/baabtra
Thanks in advance
www.baabtra.com | www.massbaab.com |www.baabte.com
Emarald Mall (Big Bazar Building)
Mavoor Road, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
NC Complex, Near Bus Stand
Mukkam, Kozhikode,
Kerala, India.
Ph: + 91 – 495 40 25 550
Cafit Square,
Hilite Business Park,
Near Pantheerankavu,
Kozhikode
Start up Village
Eranakulam,
Kerala, India.
Email: info@baabtra.com
Contact Us

More Related Content

What's hot

Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
Sujan Mia
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
Intro C# Book
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
Arpita Patel
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
Fajar Baskoro
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Arnab Bhaumik
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
HarshitaAshwani
 
pointer-to-object-.pptx
pointer-to-object-.pptxpointer-to-object-.pptx
pointer-to-object-.pptx
ZaibunnisaMalik1
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
Muhammad khan
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
backdoor
 
inheritance
inheritanceinheritance
inheritance
Nivetha Elangovan
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
Atul Sehdev
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Darpan Chelani
 
History of C#
History of C#History of C#
History of C#
aschlapsi
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
Praveen M Jigajinni
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
Sunil OS
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
C# basics
 C# basics C# basics
C# basics
Dinesh kumar
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
Nilesh Dalvi
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Lovely Professional University
 

What's hot (20)

Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 
20.3 Java encapsulation
20.3 Java encapsulation20.3 Java encapsulation
20.3 Java encapsulation
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
 
Lect 1-class and object
Lect 1-class and objectLect 1-class and object
Lect 1-class and object
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
pointer-to-object-.pptx
pointer-to-object-.pptxpointer-to-object-.pptx
pointer-to-object-.pptx
 
Template C++ OOP
Template C++ OOPTemplate C++ OOP
Template C++ OOP
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
inheritance
inheritanceinheritance
inheritance
 
itft-Inheritance in java
itft-Inheritance in javaitft-Inheritance in java
itft-Inheritance in java
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
History of C#
History of C#History of C#
History of C#
 
Chapter 07 inheritance
Chapter 07 inheritanceChapter 07 inheritance
Chapter 07 inheritance
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
C# basics
 C# basics C# basics
C# basics
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 

Viewers also liked

Inheritance
InheritanceInheritance
Inheritance
Ashish Awasthi
 
Inheritance
InheritanceInheritance
Inheritance
Guntur Sulaeman
 
Me326ppt
Me326pptMe326ppt
Me326ppt
ccatalfamo
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
Princess Sam
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
Abhishek Pratap
 
Laporan PBO Pratikum 3
Laporan PBO Pratikum 3Laporan PBO Pratikum 3
Laporan PBO Pratikum 3rahmi wahyuni
 
Harmonic and Other Sequences
Harmonic and Other SequencesHarmonic and Other Sequences
Harmonic and Other Sequences
stephendy999
 
OOP C++
OOP C++OOP C++
OOP C++
Ahmed Farag
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
Maaz Hasan
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
Princess Sam
 
ARITHMETIC MEAN AND SERIES
ARITHMETIC MEAN AND SERIESARITHMETIC MEAN AND SERIES
ARITHMETIC MEAN AND SERIES
Darwin Santos
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
home
 
Virtual function
Virtual functionVirtual function
Virtual function
harman kaur
 
Arithmetic, geometric and harmonic progression
Arithmetic, geometric and harmonic progression Arithmetic, geometric and harmonic progression
Arithmetic, geometric and harmonic progression
Dr. Trilok Kumar Jain
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
cprogrammings
 
functions of C++
functions of C++functions of C++
functions of C++
tarandeep_kaur
 
Inheritance
InheritanceInheritance
Inheritance
Sapna Sharma
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
Docent Education
 
pointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpppointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpp
gourav kottawar
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
Haresh Jaiswal
 

Viewers also liked (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Me326ppt
Me326pptMe326ppt
Me326ppt
 
Lec 45.46- virtual.functions
Lec 45.46- virtual.functionsLec 45.46- virtual.functions
Lec 45.46- virtual.functions
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
Laporan PBO Pratikum 3
Laporan PBO Pratikum 3Laporan PBO Pratikum 3
Laporan PBO Pratikum 3
 
Harmonic and Other Sequences
Harmonic and Other SequencesHarmonic and Other Sequences
Harmonic and Other Sequences
 
OOP C++
OOP C++OOP C++
OOP C++
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
ARITHMETIC MEAN AND SERIES
ARITHMETIC MEAN AND SERIESARITHMETIC MEAN AND SERIES
ARITHMETIC MEAN AND SERIES
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Arithmetic, geometric and harmonic progression
Arithmetic, geometric and harmonic progression Arithmetic, geometric and harmonic progression
Arithmetic, geometric and harmonic progression
 
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
 
functions of C++
functions of C++functions of C++
functions of C++
 
Inheritance
InheritanceInheritance
Inheritance
 
16 virtual function
16 virtual function16 virtual function
16 virtual function
 
pointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpppointers, virtual functions and polymorphisms in c++ || in cpp
pointers, virtual functions and polymorphisms in c++ || in cpp
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 

Similar to Inheritance in C++

Inheritance
InheritanceInheritance
Java
JavaJava
Java2
Java2Java2
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++
Abdullah Jan
 
C++ppt. Classs and object, class and object
C++ppt. Classs and object, class and objectC++ppt. Classs and object, class and object
C++ppt. Classs and object, class and object
secondakay
 
03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop
Vladislav Hadzhiyski
 
Inheritance
InheritanceInheritance
Inheritance
Munsif Ullah
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
DivyaKS18
 
29csharp
29csharp29csharp
29csharp
Sireesh K
 
29c
29c29c
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
DurgaPrasadVasantati
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
DurgaPrasadVasantati
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
AshokKumar587867
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
sai kumar
 
c++ introduction
c++ introductionc++ introduction
c++ introduction
sai kumar
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
sai kumar
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
mcollison
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
Saleem Thapa
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
agorolabs
 

Similar to Inheritance in C++ (20)

Inheritance
InheritanceInheritance
Inheritance
 
Java
JavaJava
Java
 
Java2
Java2Java2
Java2
 
Concept of Object-Oriented in C++
Concept of Object-Oriented in C++Concept of Object-Oriented in C++
Concept of Object-Oriented in C++
 
C++ppt. Classs and object, class and object
C++ppt. Classs and object, class and objectC++ppt. Classs and object, class and object
C++ppt. Classs and object, class and object
 
03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop03 classes interfaces_principlesofoop
03 classes interfaces_principlesofoop
 
Inheritance
InheritanceInheritance
Inheritance
 
c++ Unit I.pptx
c++ Unit I.pptxc++ Unit I.pptx
c++ Unit I.pptx
 
Classes, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptxClasses, Inheritance ,Packages & Interfaces.pptx
Classes, Inheritance ,Packages & Interfaces.pptx
 
29csharp
29csharp29csharp
29csharp
 
29c
29c29c
29c
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
unit 2 java.pptx
unit 2 java.pptxunit 2 java.pptx
unit 2 java.pptx
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
 
c++ introduction
c++ introductionc++ introduction
c++ introduction
 
c++ lecture 1
c++ lecture 1c++ lecture 1
c++ lecture 1
 
Pi j3.1 inheritance
Pi j3.1 inheritancePi j3.1 inheritance
Pi j3.1 inheritance
 
Classes and objects
Classes and objectsClasses and objects
Classes and objects
 
Java 102 intro to object-oriented programming in java
Java 102   intro to object-oriented programming in javaJava 102   intro to object-oriented programming in java
Java 102 intro to object-oriented programming in java
 

More from baabtra.com - No. 1 supplier of quality freshers

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
baabtra.com - No. 1 supplier of quality freshers
 
Best coding practices
Best coding practicesBest coding practices
Core java - baabtra
Core java - baabtraCore java - baabtra
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
baabtra.com - No. 1 supplier of quality freshers
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
baabtra.com - No. 1 supplier of quality freshers
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
baabtra.com - No. 1 supplier of quality freshers
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php database connectivity
Php database connectivityPhp database connectivity
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
baabtra.com - No. 1 supplier of quality freshers
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Blue brain
Blue brainBlue brain
5g
5g5g
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Gd baabtra
Gd baabtraGd baabtra

More from baabtra.com - No. 1 supplier of quality freshers (20)

Agile methodology and scrum development
Agile methodology and scrum developmentAgile methodology and scrum development
Agile methodology and scrum development
 
Best coding practices
Best coding practicesBest coding practices
Best coding practices
 
Core java - baabtra
Core java - baabtraCore java - baabtra
Core java - baabtra
 
Acquiring new skills what you should know
Acquiring new skills   what you should knowAcquiring new skills   what you should know
Acquiring new skills what you should know
 
Baabtra.com programming at school
Baabtra.com programming at schoolBaabtra.com programming at school
Baabtra.com programming at school
 
99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love 99LMS for Enterprises - LMS that you will love
99LMS for Enterprises - LMS that you will love
 
Php sessions & cookies
Php sessions & cookiesPhp sessions & cookies
Php sessions & cookies
 
Php database connectivity
Php database connectivityPhp database connectivity
Php database connectivity
 
Chapter 6 database normalisation
Chapter 6  database normalisationChapter 6  database normalisation
Chapter 6 database normalisation
 
Chapter 5 transactions and dcl statements
Chapter 5  transactions and dcl statementsChapter 5  transactions and dcl statements
Chapter 5 transactions and dcl statements
 
Chapter 4 functions, views, indexing
Chapter 4  functions, views, indexingChapter 4  functions, views, indexing
Chapter 4 functions, views, indexing
 
Chapter 3 stored procedures
Chapter 3 stored proceduresChapter 3 stored procedures
Chapter 3 stored procedures
 
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
Chapter 2  grouping,scalar and aggergate functions,joins   inner join,outer joinChapter 2  grouping,scalar and aggergate functions,joins   inner join,outer join
Chapter 2 grouping,scalar and aggergate functions,joins inner join,outer join
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Microsoft holo lens
Microsoft holo lensMicrosoft holo lens
Microsoft holo lens
 
Blue brain
Blue brainBlue brain
Blue brain
 
5g
5g5g
5g
 
Aptitude skills baabtra
Aptitude skills baabtraAptitude skills baabtra
Aptitude skills baabtra
 
Gd baabtra
Gd baabtraGd baabtra
Gd baabtra
 

Recently uploaded

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 

Recently uploaded (20)

Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 

Inheritance in C++

  • 1.
  • 3. CONTENTS • CLASS BASE CLASS DERIVED CLASS • OBJECT • INHERITANCE SINGLE INHERITANCE MULTIPLE INHERITANCE HIERARCHICAL INHERITANCE MULTILEVEL INHERITANCE HYBRID INHERITANS(Virtual Inheritance)
  • 4. CLASS • Class is the base design of objects means expanded concept of a data, that can hold both data and functions. • No memory is allocated when class is created. • It is a user defined data type. Example : A car is consider as a class Methods : Engine, wheels, steering. Properties : company, model, colour, speed, etc….
  • 5. BASE CLASS • The class from which the subclass is derived is called a superclass (also a base class or a parent class). DERIVED CLASS • A class that is derived from another class is called a subclass (also a derived class, extended class, or child class).
  • 6. OBJECT • Object is the instance of class, means identifiable entity with some characteristics and behaviour. • Memory allocated when only an object is created.
  • 7. EXAMPLE PROGRAM : #include <iostream> using namespace std; class person { public: string name; int number; }; int main() { person obj; cout<<"Enter the Name :"; cin>>obj.name; cout<<"Enter the Number :"; cin>>obj.number; cout << obj.name<< obj.number; } Output : Enter the name : baabtra Enter the number:123 baabtra123
  • 8. INHERITANCE  Deriving new class from existing class.  Object of one class contains the property of another class.  Reusability.  We can add features to an existing class without modifying it.
  • 9. TYPES OF INHERITANCE • Single Inheritance • Hierarchical Inheritance • Multi Level Inheritance • Hybrid Inheritance • Multiple Inheritance
  • 10. SINGLE INHERITANCE • One derived class inherits from only one base class • Most simplest form of Inheritance.
  • 11. EXAMPLE #include<iostream> using namespace std; class father { public: string name; int age,pincode; }; class child:public father { public: string school; int standard; }; main() { father obj1; child obj2; cout<<"enter the name of father:"; cin>>obj1.name; cout<<"enter the age of father:"; cin>>obj1.age; cout<<"enter the pincode of father:"; cin>>obj1.pincode; cout<<"-------------DETAIL OF CHILD--------------n"; cout<<"enter the name of child:"; cin>>obj2.name; cout<<"enter the age of child:"; cin>>obj2.age; cout<<"enter the pincode of child:"; cin>>obj2.pincode; cout<<"enter the school name of child:"; cin>>obj2.school; cout<<"enter the standard of child:"; cin>>obj2.standard; }
  • 12. HEIRARCHICAL INHERITANCE • More than one derived classes is derived from common base class.
  • 13. EXAMPLE #include<iostream> using namespace std; class user { public: string name,place; int age; }; class student:public user { public: int rollno,classs,mark1,mark2; }; class teacher:public user { public: string department; int teacher_id,salary; }; main() { user obj; student obj1; teacher obj2; cout<<"-----------------STUDENT-------------n"; cout<<"enter the name:"; cin>>obj1.name; cout<<"enter the age:"; cin>>obj1.age; cout<<"enter the place:"; cin>>obj1.place; cout<<"enter the rollno:"; cin>>obj1.rollno; cout<<"enter the class:"; cin>>obj1.classs; cout<<"enter the mark1:"; cin>>obj1.mark1; cout<<"enter the mark2:"; cin>>obj1.mark2; cout<<"---------------TEACHER---------------n"; cout<<"enter the name:"; cin>>obj2.name; cout<<"enter the age:"; cin>>obj2.age; cout<<"enter the place:"; cin>>obj2.place; cout<<"enter the id:"; cin>>obj2.teacher_id; cout<<"enter the salary:"; cin>>obj2.salary; cout<<"enter the department:"; cin>>obj2.department; }
  • 14. MULTI LEVEL INHERITANCE • Derived class is derived from another derived class.
  • 15. EXAMPLE #include<iostream> using namespace std; class grandparent { public: void gshow() { cout<<"intelligent"; } }; class parent:public grandparent { public: void pshow() { cout<<"nhandsom"; } }; class child:public parent { public: void cshow() { cout<<"nobedience"; } }; main() { grandparent obj1; parent obj2; child obj3; cout<<"QUALITY OF GRANDPAn"; obj1.gshow(); cout<<"nQUALITIES OF FATHERn"; obj2.gshow(); obj2.pshow(); cout<<"nQUALITIES OF CHILDn"; obj3.gshow(); obj3.pshow(); obj3.cshow(); }
  • 16. HYBRID INHERITANCE • Combination of single Inheritance , hierarchical inheritance and multi level inheritance.
  • 17. EXAMPLE #include<iostream> using namespace std; class grandparent { public:void gshow() { cout<<"nintelligent"; } }; class parent:public grandparent { public: void pshow() { cout<<"neducated"; } }; class son:public parent { public: void sshow() { cout<<"nobedience"; } }; class daugter:public parent { public: void dshow() { cout<<"nbeautiful"; } }; main() { grandparent gobj; parent pobj; son sobj; daugter dobj; cout<<"QUALITY OF GRANDPA"; gobj.gshow(); cout<<"nQUALITY OF PARENT"; pobj.gshow(); pobj.pshow(); cout<<"nQUALITIES OF SON"; sobj.sshow(); sobj.pshow(); sobj.gshow(); cout<<"nQUALITIES OF DAUGHTER"; dobj.dshow(); dobj.pshow(); dobj.gshow(); }
  • 18. MULTIPLE INHERITANCE • Derived class is derived from more than one base class.
  • 19. EXAMPLE #include<iostream> using namespace std; class father { public: void fshow() { cout<<"discipline"; } }; class mother { public: void mshow() { cout<<"nopen minded"; } }; class child:public father,public mother { public: void cshow() { cout<<"nintelligent"; } }; main() { father obj1; mother obj2; child obj3; cout<<"QUALITY OF FATHERn"; obj1.fshow(); cout<<"n"; cout<<"nQUALITY OF MOTHER"; obj2.mshow(); cout<<"n"; cout<<"nQUALITIES OF CHILDn"; obj3.fshow(); obj3.mshow(); obj3.cshow(); }
  • 20. Disclaimer: This presentation is prepared by trainees of baabtra as a part of mentoring program. This is not official document of baabtra –Mentoring Partner Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt . Ltd
  • 21. Follow us @ twitter.com/baabtra Like us @ facebook.com/baabtra Subscribe to us @ youtube.com/baabtra Become a follower @ slideshare.net/BaabtraMentoringPartner Connect to us @ in.linkedin.com/in/baabtra Give a feedback @ massbaab.com/baabtra Thanks in advance www.baabtra.com | www.massbaab.com |www.baabte.com
  • 22. Emarald Mall (Big Bazar Building) Mavoor Road, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 NC Complex, Near Bus Stand Mukkam, Kozhikode, Kerala, India. Ph: + 91 – 495 40 25 550 Cafit Square, Hilite Business Park, Near Pantheerankavu, Kozhikode Start up Village Eranakulam, Kerala, India. Email: info@baabtra.com Contact Us