SlideShare uma empresa Scribd logo
1 de 37
Presentation Group Members :-
08. Ankita
14. Ashutosh
18. Samiksha
19. Laxman
S.Y.BSc.(Computer Science)
I
Types of Inheritance :-
Demo !!!!
Doubt & Question Session ????
Single
Inheritance
Multilevel
Inheritance
Multiple
Inheritance
Hierarchal
Inheritance
Hybrid
Inheritance
class base_class_name
{
access specifier:
:
};
Class derived_class_name : access specifier base_class_name
{
access specifier:
:
};
void A :: getdata ()
{
cout<<"nn Enter value
a:";
cin>>a;
cout<<"Enter value b:";
cin>>b;
}
void B :: calculate ()
{
c = (a + b);
}
void B :: display ()
{
cout<<"n"<<a<<"+"<<b<
<"="<<c;
}
Access Public Protected Private
Same class/
Base class
yes yes yes
Derived
classes
yes yes no
Outside
classes
yes no no
Public inheritance
Base access specifier
Derived access
specifier
Derived class access? Public access?
Public Public Yes Yes
Private Private No No
Protected Protected Yes No
Private inheritance
Base access specifier
Derived access
specifier
Derived class access? Public access?
Public Private Yes No
Private Private No No
Protected Private Yes No
Protected inheritance
Base access specifier
Derived access
specifier
Derived class access? Public access?
Public Protected Yes No
Private Private No No
Protected Protected Yes No
class derived class_name:<access_specifier>
class1_name,<access_specifier>
class2_name,………………………………………..,
<access_specifier> classn_name
{
:
: //members of derived class
:
}
SYNTAX:
class sub : public superA, private
superB
{
:
: //members of class sub
:
}
FOR INSTANCE:
Multilevel Inheritance :-
Definition:
“It is the inheritance hierarchy wherein subclass acts as a
base class for other classes”
It is implemented by defining at least three classes.
In multilevel inheritance, there is one base class and the
remaining two is derived class.
Declaration :-
class A
{………..
……….}; // Base class
class B : public A
{………..
……….}; // B derived from A
class C : public B
{……….
………}; // C derived from B
Fig. Multilevel Inheritance :-
Student
Test
Records
Result
Base Class
Intermediate
base class
Hybrid inheritance :-
Definition:
“Inheritance hierarchy that reflects any legal combination of
other four types of inheritance.”
Simple word:-
“The method of combining any two or more forms of
inheritance in single form is called hybrid inheritance.”
Fig. Hybrid Inheritance :-
Student
Test
Records
Result
Sports
Base
class
Intermediate
base class
Derived
class
Base
class
class A
{……….
………};
class B:public A
{……….
……….};
class C
{……….
………};
class D: public b, public c
{……….
……….};
Constructors in Inheritance :-
• Base class constructors are automatically called for you if
they have no argument.
• If you want to call a superclass constructor with an argument,
you must use the subclass's constructor initialization list.
• C++ supports multiple inheritance (for better or worse), so the
base class must be referred to by name, rather than "super()".
Constructor Example :-
class SuperClass
{
public:
SuperClass(int foo)
{ // do something with foo }
};
class SubClass : public SuperClass
{
public: SubClass(int foo, int bar) : SuperClass(foo)
{ // do something with bar }
};
Virtual keyword determines if a member function of a class can
be over-ridden in its derived classes.
The non-virtual member functions are resolved at compiling
time and it’s called static binding. However, the c++ virtual
member functions are resolved during runtime and it’s called
as dynamic binding
Virtual Class :-
For your Attention !!!!

Mais conteúdo relacionado

Mais procurados

Virtual base class
Virtual base classVirtual base class
Virtual base class
Tech_MX
 
Friend functions
Friend functions Friend functions
Friend functions
Megha Singh
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
Tech_MX
 

Mais procurados (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Inheritance in Object Oriented Programming
Inheritance in Object Oriented ProgrammingInheritance in Object Oriented Programming
Inheritance in Object Oriented Programming
 
Friend functions
Friend functions Friend functions
Friend functions
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
C++ Inheritance Tutorial | Introduction To Inheritance In C++ Programming Wit...
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Operators and expressions in C++
Operators and expressions in C++Operators and expressions in C++
Operators and expressions in C++
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Inheritance in java
Inheritance in java Inheritance in java
Inheritance in java
 
Function overloading ppt
Function overloading pptFunction overloading ppt
Function overloading ppt
 
friend function(c++)
friend function(c++)friend function(c++)
friend function(c++)
 
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...
 
Linked list
Linked listLinked list
Linked list
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Polymorphism presentation in java
Polymorphism presentation in javaPolymorphism presentation in java
Polymorphism presentation in java
 
Inheritance
InheritanceInheritance
Inheritance
 

Destaque

Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Inheritance
InheritanceInheritance
Inheritance
Tech_MX
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritance
harshaltambe
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
file handling c++
file handling c++file handling c++
file handling c++
Guddu Spy
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
Baljit Saini
 

Destaque (20)

inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Inheritance
InheritanceInheritance
Inheritance
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 
Java inheritance
Java inheritanceJava inheritance
Java inheritance
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: Inheritance
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritance
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
Inheritance
InheritanceInheritance
Inheritance
 
file handling c++
file handling c++file handling c++
file handling c++
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
pointers,virtual functions and polymorphism
pointers,virtual functions and polymorphismpointers,virtual functions and polymorphism
pointers,virtual functions and polymorphism
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Inheritance Presentation
Inheritance PresentationInheritance Presentation
Inheritance Presentation
 
Inheritance
InheritanceInheritance
Inheritance
 
inheritance
inheritanceinheritance
inheritance
 
Templates exception handling
Templates exception handlingTemplates exception handling
Templates exception handling
 

Semelhante a Inheritance in C++

INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
DeepasCSE
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
deepakskb2013
 

Semelhante a Inheritance in C++ (20)

12 constructors invocation and data members initialization
12 constructors invocation and data members initialization12 constructors invocation and data members initialization
12 constructors invocation and data members initialization
 
12 constructors invocation and data members initialization
12 constructors invocation and data members initialization12 constructors invocation and data members initialization
12 constructors invocation and data members initialization
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
MODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computerMODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computer
 
Inheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ optInheritance chapter-6-computer-science-with-c++ opt
Inheritance chapter-6-computer-science-with-c++ opt
 
c++Inheritance.pdf
c++Inheritance.pdfc++Inheritance.pdf
c++Inheritance.pdf
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
Inheritance
InheritanceInheritance
Inheritance
 
week14 (1).ppt
week14 (1).pptweek14 (1).ppt
week14 (1).ppt
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
 
Ritik (inheritance.cpp)
Ritik (inheritance.cpp)Ritik (inheritance.cpp)
Ritik (inheritance.cpp)
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
Learn Java Part 11
Learn Java Part 11Learn Java Part 11
Learn Java Part 11
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
Inheritance slides
Inheritance slidesInheritance slides
Inheritance slides
 
OOP
OOPOOP
OOP
 
Lecturespecial
LecturespecialLecturespecial
Lecturespecial
 

Mais de Laxman Puri (7)

Remote access from a smartphone ppt
Remote access from a smartphone pptRemote access from a smartphone ppt
Remote access from a smartphone ppt
 
Processors
ProcessorsProcessors
Processors
 
Dbms rlde.ppt
Dbms rlde.pptDbms rlde.ppt
Dbms rlde.ppt
 
Co relation between dfd & event table
Co relation between dfd & event tableCo relation between dfd & event table
Co relation between dfd & event table
 
Python Programming Language
Python Programming LanguagePython Programming Language
Python Programming Language
 
Java byte code & virtual machine
Java byte code & virtual machineJava byte code & virtual machine
Java byte code & virtual machine
 
Clipping in Computer Graphics
Clipping in Computer GraphicsClipping in Computer Graphics
Clipping in Computer Graphics
 

Último

CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
anilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 

Inheritance in C++