SlideShare a Scribd company logo
INHERITANCE
Inheritance is the ability of one class to inherit the properties of another class. A new class can becreated from an existing class.  The existing class iscalled the Base class or Super class and the new class is called  the Derived class or Sub-class.e.g:Car inherits from another class auto-mobile.Science student inherits from class student
Advantages of Inheritance:Reusability of code Size of the code is reduced.Transitivity:	If  B is derived from A and C is derived from B     then C is also derived from A.
Person  -   Base ClassStudent -  Derived class
inheritance c++
inheritance c++
QUADRILATERALSQUARE                       RECTANGLE                      RHOMBUS
inheritance c++
inheritance c++
Identify the type of  inheritance:2009 DELHIclass FacetoFace{      char CenterCode[10];  public:      void Input();       void Output()   };class Online{       char website[50];      public:    void SiteIn();    void SiteOut();     };
class Training : public  FacetoFace, private Online{	long Tcode;	float Charge;int Period;      public:              void Register();              void Show();};:
Base Classes:FacetoFace          OnlineDerived Class:TrainingMultiple base classes   so    multiple inheritance
DelhiClass Dolls{	char Dcode[5];   protected:     float price;     void CalcPrice(float);Public:    Dolls();    void Dinput();    void Dshow();};
class  SoftDolls: public Dolls{      char SDName[20];       float Weight;public:SoftDolls();       void SDInput();       void SDShow();};class ElectronicDolls:  public Dolls{      char EDName[20];      char BatteryType[10];int Batteries; public:ElectronicDolls();       void EDInput();       void EDShow();};
BASE CLASS:   DOLLSElectronicDollsSoftDollsHIERARCHICAL INHERITANCE
Out-side Delhi 2006class furniture {       char Type;      char Model[10];    public:      furniture();    void Read_fur_Details();    void Disp_fur_Details();   };class Sofa : public furniture{intno_of_seats;    float cost_of_sofa;public:   void Read_sofa_details();   void Disp_sofa_details();};
class office : private  Sofa{intno_of_pieces;       char Delivery_date[10];    public:   void Read_office_details();   void Disp_office_details();};Void main(){     office MyFurniture;}
FurnitureSofaofficeSofa is derived from furnitureOffice is derived from sofa.Multi-level Inheritance
Visibility ModesIt can be public, private or protected. The private data of base class cannot be inherited.(i) If inheritance is done in public mode, public members of the base class becomethe public members of derived class and protected members of base class become the protected members of derived class.(ii) If inheritance is done in a private mode, public and protected members of  base class become the private members of derived class.(iii) If inheritance is done in a protected mode, public and protected members of base class become the protected members of derived class.
Accessibility of Base Class members:
#include<iostream.h>class one{int a;   // only for class members	 protected:int b;    // for class members and derived classes	 public:int c;   // for class members, derived classes, main	 one()	 {		  a=3;		  b=5;		  c=10;		  }	  void show()	  {cout<<a<<":"<<b<<":"<<c<<endl;		 }		 };
	 class two :public one	 {int p;		  public:		  two()		  {				p=25;				}		  void show1()		  {cout<<a<<endl;  \\ error.  Not accessiblecout<<b<<endl; \\o.k.cout<<c<<endl; \\o.k.			  }			  };
class three : public two	 {int x;			public :			three()			{				x=100;				}				void show2()				{cout<<x<<endl; \\o.k.cout<<p<<endl; \\error. Not accessiblecout<<b<<endl; \\o.k.cout<<c<<endl; \\o.k.					}					};
int main()		{				three ob;cout<<ob.c<<endl; \\o.k. public membercout<<ob.b<<endl; \\ error.  Not availableob.show();				ob.show1();				ob.show2();				return 0;                                                               }
#include<iostream.h>class one{int a;   // only for class members	 protected:int b;    // for class members and derived classes	 public:int c;   // for class members, derived classes,main	 one()	 {		  a=3;		  b=5;		  c=10;		  }	  void show()	  {cout<<a<<":"<<b<<":"<<c<<endl;		 }		 };
class two :protected one	 {int p;		  public:		  two()		  {				p=25;				}		  void show1()		  {cout<<a<<endl;  // error.  Not accessiblecout<<b<<endl; // o.k. protectedcout<<c<<endl; // o.k. becomes protected			  }			  };
class three : protected  two	 {int x;			public :			three()			{				x=100;				}				void show2()				{cout<<x<<endl; // o.k. its own member				cout<<p<<endl; // error. Not accessiblecout<<b<<endl; // o.k. protected				cout<<c<<endl; // o.k. has become protected					}					};
int main()			{			three ob;cout<<ob.c<<endl; // error has become protected not availablecout<<ob.b<<endl; // error.  Not available   				ob.show();   // error.  Has become protected not available	ob.show1();  // error.  Has become protected not available 	ob.show2(); // O.K.	return 0;				}
#include<iostream.h>class one{int a;   // only for class members	 protected:int b;    // for class members and derived classes	 public:int c;   // for class members, derived classes, main	 one()	 {		  a=3;		  b=5;		  c=10;		  }	  void show()	  {cout<<a<<":"<<b<<":"<<c<<endl;		 }		 };
	 class two :private  one	 {int p;		  public:		  two()		  {				p=25;				}		  void show1()		  {cout<<p<<endl; // o.k. its own membercout<<a<<endl;  // error.  Not accessiblecout<<b<<endl; // error.  has become private .cout<<c<<endl; // error .  has become private						  }			  };
class three : private   two	 {int x;			public :			three()			{			x=100;				}		void show2()				{					cout<<x<<endl; // o.k. its own membercout<<p<<endl; // error. Not accessible				cout<<b<<endl; // error.  not availablecout<<c<<endl; // error. not available					}				};
int main()			{			three ob;cout<<ob.c<<endl; // error not available		cout<<ob.b<<endl; // error.  Not available		ob.show();   // error.   not available			ob.show1();  // error . not available			ob.show2(); // o.k. its own member			return 0;				}
Ad

More Related Content

What's hot (20)

Access specifier
Access specifierAccess specifier
Access specifier
zindadili
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
Rajab Ali
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Paumil Patel
 
Friend function in c++
Friend function in c++ Friend function in c++
Friend function in c++
University of Madras
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Member Function in C++
Member Function in C++ Member Function in C++
Member Function in C++
NikitaKaur10
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
Edureka!
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
Nilesh Dalvi
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Access specifiers(modifiers) in java
Access specifiers(modifiers) in javaAccess specifiers(modifiers) in java
Access specifiers(modifiers) in java
HrithikShinde
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
BG Java EE Course
 
Access specifier
Access specifierAccess specifier
Access specifier
zindadili
 
Function overloading and overriding
Function overloading and overridingFunction overloading and overriding
Function overloading and overriding
Rajab Ali
 
Function overloading(c++)
Function overloading(c++)Function overloading(c++)
Function overloading(c++)
Ritika Sharma
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Paumil Patel
 
08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt08 c++ Operator Overloading.ppt
08 c++ Operator Overloading.ppt
Tareq Hasan
 
Member Function in C++
Member Function in C++ Member Function in C++
Member Function in C++
NikitaKaur10
 
How to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | EdurekaHow to use Map() Filter() and Reduce() functions in Python | Edureka
How to use Map() Filter() and Reduce() functions in Python | Edureka
Edureka!
 
Lecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptxLecture_7-Encapsulation in Java.pptx
Lecture_7-Encapsulation in Java.pptx
ShahinAhmed49
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
Nilesh Dalvi
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Java abstract class & abstract methods
Java abstract class & abstract methodsJava abstract class & abstract methods
Java abstract class & abstract methods
Shubham Dwivedi
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 
Super keyword in java
Super keyword in javaSuper keyword in java
Super keyword in java
Hitesh Kumar
 
Access specifiers(modifiers) in java
Access specifiers(modifiers) in javaAccess specifiers(modifiers) in java
Access specifiers(modifiers) in java
HrithikShinde
 
Inline function
Inline functionInline function
Inline function
Tech_MX
 
Object-oriented Programming-with C#
Object-oriented Programming-with C#Object-oriented Programming-with C#
Object-oriented Programming-with C#
Doncho Minkov
 

Similar to inheritance c++ (20)

inhertance c++
inhertance c++inhertance c++
inhertance c++
abhilashagupta
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
RutujaTandalwade
 
labwork practice on inhetitance-1.pptx
labwork  practice on  inhetitance-1.pptxlabwork  practice on  inhetitance-1.pptx
labwork practice on inhetitance-1.pptx
soniasharmafdp
 
Inheritance
InheritanceInheritance
Inheritance
poonam.rwalia
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
study material
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
farhan amjad
 
Object Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptxObject Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptx
RashidFaridChishti
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
FALLEE31188
 
Oop Presentation
Oop PresentationOop Presentation
Oop Presentation
Ganesh Samarthyam
 
Introduction to inheritance and different types of inheritance
Introduction to inheritance and different types of inheritanceIntroduction to inheritance and different types of inheritance
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
Object Oriented Programming (OOP) using C++ - Lecture 4
Object Oriented Programming (OOP) using C++ - Lecture 4Object Oriented Programming (OOP) using C++ - Lecture 4
Object Oriented Programming (OOP) using C++ - Lecture 4
Faculty of Computers and Informatics, Suez Canal University, Ismailia, Egypt
 
Lecture4
Lecture4Lecture4
Lecture4
FALLEE31188
 
Lecture4
Lecture4Lecture4
Lecture4
rajesh0ks
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
00ps inheritace using c++
00ps inheritace using c++00ps inheritace using c++
00ps inheritace using c++
sushamaGavarskar1
 
Inheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridInheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybrid
VGaneshKarthikeyan
 
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
 
C++ Language
C++ LanguageC++ Language
C++ Language
Vidyacenter
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
Vinay Kumar
 
Inheritance
InheritanceInheritance
Inheritance
Misbah Aazmi
 
labwork practice on inhetitance-1.pptx
labwork  practice on  inhetitance-1.pptxlabwork  practice on  inhetitance-1.pptx
labwork practice on inhetitance-1.pptx
soniasharmafdp
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
study material
 
Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)Inheritance, polymorphisam, abstract classes and composition)
Inheritance, polymorphisam, abstract classes and composition)
farhan amjad
 
Object Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptxObject Oriented Programming using C++: Ch09 Inheritance.pptx
Object Oriented Programming using C++: Ch09 Inheritance.pptx
RashidFaridChishti
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
FALLEE31188
 
Introduction to inheritance and different types of inheritance
Introduction to inheritance and different types of inheritanceIntroduction to inheritance and different types of inheritance
Introduction to inheritance and different types of inheritance
huzaifaakram12
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
Inheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybridInheritance_with_its_types_single_multi_hybrid
Inheritance_with_its_types_single_multi_hybrid
VGaneshKarthikeyan
 
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
 
Access controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modesAccess controlaspecifier and visibilty modes
Access controlaspecifier and visibilty modes
Vinay Kumar
 
Ad

Recently uploaded (20)

The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
The role of wall art in interior designing
The role of wall art in interior designingThe role of wall art in interior designing
The role of wall art in interior designing
meghaark2110
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Rock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian HistoryRock Art As a Source of Ancient Indian History
Rock Art As a Source of Ancient Indian History
Virag Sontakke
 
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
PHYSIOLOGY MCQS By DR. NASIR MUSTAFA (PHYSIOLOGY)
Dr. Nasir Mustafa
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx2025 The Senior Landscape and SET plan preparations.pptx
2025 The Senior Landscape and SET plan preparations.pptx
mansk2
 
Cultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptxCultivation Practice of Turmeric in Nepal.pptx
Cultivation Practice of Turmeric in Nepal.pptx
UmeshTimilsina1
 
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon DolabaniHistory Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
History Of The Monastery Of Mor Gabriel Philoxenos Yuhanon Dolabani
fruinkamel7m
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptxTERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
TERMINOLOGIES,GRIEF PROCESS AND LOSS AMD ITS TYPES .pptx
PoojaSen20
 
How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18How to Configure Public Holidays & Mandatory Days in Odoo 18
How to Configure Public Holidays & Mandatory Days in Odoo 18
Celine George
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18How to Configure Scheduled Actions in odoo 18
How to Configure Scheduled Actions in odoo 18
Celine George
 
E-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26ASE-Filing_of_Income_Tax.pptx and concept of form 26AS
E-Filing_of_Income_Tax.pptx and concept of form 26AS
Abinash Palangdar
 
Ad

inheritance c++

  • 2. Inheritance is the ability of one class to inherit the properties of another class. A new class can becreated from an existing class. The existing class iscalled the Base class or Super class and the new class is called the Derived class or Sub-class.e.g:Car inherits from another class auto-mobile.Science student inherits from class student
  • 3. Advantages of Inheritance:Reusability of code Size of the code is reduced.Transitivity: If B is derived from A and C is derived from B then C is also derived from A.
  • 4. Person - Base ClassStudent - Derived class
  • 7. QUADRILATERALSQUARE RECTANGLE RHOMBUS
  • 10. Identify the type of inheritance:2009 DELHIclass FacetoFace{ char CenterCode[10]; public: void Input(); void Output() };class Online{ char website[50]; public: void SiteIn(); void SiteOut(); };
  • 11. class Training : public FacetoFace, private Online{ long Tcode; float Charge;int Period; public: void Register(); void Show();};:
  • 12. Base Classes:FacetoFace OnlineDerived Class:TrainingMultiple base classes so multiple inheritance
  • 13. DelhiClass Dolls{ char Dcode[5]; protected: float price; void CalcPrice(float);Public: Dolls(); void Dinput(); void Dshow();};
  • 14. class SoftDolls: public Dolls{ char SDName[20]; float Weight;public:SoftDolls(); void SDInput(); void SDShow();};class ElectronicDolls: public Dolls{ char EDName[20]; char BatteryType[10];int Batteries; public:ElectronicDolls(); void EDInput(); void EDShow();};
  • 15. BASE CLASS: DOLLSElectronicDollsSoftDollsHIERARCHICAL INHERITANCE
  • 16. Out-side Delhi 2006class furniture { char Type; char Model[10]; public: furniture(); void Read_fur_Details(); void Disp_fur_Details(); };class Sofa : public furniture{intno_of_seats; float cost_of_sofa;public: void Read_sofa_details(); void Disp_sofa_details();};
  • 17. class office : private Sofa{intno_of_pieces; char Delivery_date[10]; public: void Read_office_details(); void Disp_office_details();};Void main(){ office MyFurniture;}
  • 18. FurnitureSofaofficeSofa is derived from furnitureOffice is derived from sofa.Multi-level Inheritance
  • 19. Visibility ModesIt can be public, private or protected. The private data of base class cannot be inherited.(i) If inheritance is done in public mode, public members of the base class becomethe public members of derived class and protected members of base class become the protected members of derived class.(ii) If inheritance is done in a private mode, public and protected members of base class become the private members of derived class.(iii) If inheritance is done in a protected mode, public and protected members of base class become the protected members of derived class.
  • 20. Accessibility of Base Class members:
  • 21. #include<iostream.h>class one{int a; // only for class members protected:int b; // for class members and derived classes public:int c; // for class members, derived classes, main one() { a=3; b=5; c=10; } void show() {cout<<a<<":"<<b<<":"<<c<<endl; } };
  • 22. class two :public one {int p; public: two() { p=25; } void show1() {cout<<a<<endl; \\ error. Not accessiblecout<<b<<endl; \\o.k.cout<<c<<endl; \\o.k. } };
  • 23. class three : public two {int x; public : three() { x=100; } void show2() {cout<<x<<endl; \\o.k.cout<<p<<endl; \\error. Not accessiblecout<<b<<endl; \\o.k.cout<<c<<endl; \\o.k. } };
  • 24. int main() { three ob;cout<<ob.c<<endl; \\o.k. public membercout<<ob.b<<endl; \\ error. Not availableob.show(); ob.show1(); ob.show2(); return 0; }
  • 25. #include<iostream.h>class one{int a; // only for class members protected:int b; // for class members and derived classes public:int c; // for class members, derived classes,main one() { a=3; b=5; c=10; } void show() {cout<<a<<":"<<b<<":"<<c<<endl; } };
  • 26. class two :protected one {int p; public: two() { p=25; } void show1() {cout<<a<<endl; // error. Not accessiblecout<<b<<endl; // o.k. protectedcout<<c<<endl; // o.k. becomes protected } };
  • 27. class three : protected two {int x; public : three() { x=100; } void show2() {cout<<x<<endl; // o.k. its own member cout<<p<<endl; // error. Not accessiblecout<<b<<endl; // o.k. protected cout<<c<<endl; // o.k. has become protected } };
  • 28. int main() { three ob;cout<<ob.c<<endl; // error has become protected not availablecout<<ob.b<<endl; // error. Not available ob.show(); // error. Has become protected not available ob.show1(); // error. Has become protected not available ob.show2(); // O.K. return 0; }
  • 29. #include<iostream.h>class one{int a; // only for class members protected:int b; // for class members and derived classes public:int c; // for class members, derived classes, main one() { a=3; b=5; c=10; } void show() {cout<<a<<":"<<b<<":"<<c<<endl; } };
  • 30. class two :private one {int p; public: two() { p=25; } void show1() {cout<<p<<endl; // o.k. its own membercout<<a<<endl; // error. Not accessiblecout<<b<<endl; // error. has become private .cout<<c<<endl; // error . has become private } };
  • 31. class three : private two {int x; public : three() { x=100; } void show2() { cout<<x<<endl; // o.k. its own membercout<<p<<endl; // error. Not accessible cout<<b<<endl; // error. not availablecout<<c<<endl; // error. not available } };
  • 32. int main() { three ob;cout<<ob.c<<endl; // error not available cout<<ob.b<<endl; // error. Not available ob.show(); // error. not available ob.show1(); // error . not available ob.show2(); // o.k. its own member return 0; }
  翻译: