SlideShare a Scribd company logo
  INHERITANCE
[object Object],[object Object],[object Object]
Types of Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object]
SINGLE INHERITANCE ,[object Object],[object Object],[object Object],A B
When a derived class inherit from multiple base classes it is known as multiple Inheritance. A B C MULTIPLE INHERITANCE Base Class Derived Class
MULTILEVEL INHERITANCE ,[object Object],[object Object],[object Object],[object Object],[object Object],A B C
HYBRID   INHERITANCE ,[object Object],w x y z
HIERARCHICAL INHERITANCE ,[object Object],[object Object],[object Object],a b c d
A general form to defining a derived class is: Class derived class name: visibility mode  base class  name {  members of derived class }  ; Class ABC: public XYZ {  members of ABC };  DEFINING DERIVED CLASS
Example of derived class definition is: Class Sub : public Super   public derivation {  ………  members of sub }; Class Sub: private Super   private derivation { …… ...  members of sub }; Class Sub: protected Super   protected derivation { …… ...  members of sub };
MULTIPLE INHERITANCE Example of derived class definition is: Class derived_class : vis_mode base1, vis_mode base 2 { ………… .  members of derived class }; Class Sub : public SuperA, private SuperB {  ………  members of sub };
Visibility Modes ,[object Object],[object Object],[object Object]
Private Visibility Mode-   The public and protected members of the base class become private members of the derived class. The inherited members can only be accessed only through the member function of derived class. Protected Visibility Mode-   The public and protected members of base class become protected members of the derived class.
Visibility of Inherited base class members in Derived Class. Visibility Mode Public members of base class becomes Protected members of base class becomes Private members of the base class is not accessible to the derived class. Public Public Protected Protected Protected Protected Private Private Private
Accessibility of Base class members  No No Yes Private No Yes Yes Protected Yes Yes Yes Public Accessible from objects outside class Accessible from derived class Accessible from own class Access Specifier
Inheritance and Constructors and Destructors  ,[object Object],[object Object]
Class super  { …… . }; Class Sub : public Super  { ….. }; int main() {  sub ob1; …… . }
Base class Constructors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class Base { int a;  float b; public : Base(int I, float j) { a = i;  b = j; } … }; Class Derived : public Base {…. Public :  Derived ( int p, float q) : Base (p , q)  {  } }; Even if derived const does not need a parameter, yet it accepts parameter for base const.
Class Base { int a;  float b; public : Base( int i, float j) { a = i;  b = j; } … }; Class Derived : public Base { int x; float y; Public :  Derived ( int i, int j , int p, float q) : Base (p , q)  {  x = i ; Y = j ;  } }; Derived Const is accepting parameter for itself( i ,j) and ( p , q) for Base const
Constructor in Derived Class ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class gamma: public beta, public alpha { int k; public: gamma(int a,float b, int c): alpha(a) , beta(b) { k=c; } void show() { cout<<“1”<<x<<“2”<<y<<“3”<<k; }}; void main() { gamma g(14,15.2,17); g.show(); }
Facts about inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Abstract class A class that serves only as a base class from which other classes can be derived, but no objects of this base type exist, is known as abstract class.
Constructors in Multiple inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Class base2  {  Protected : int b; public : Base2(int y) {  b = y;  cout<<“Constructing Base2”;  } ~Base2 ( ) {  cout<< Destructing Base2 “;  } }; Class derived : public Base2, public Base1 {  int c; public :  derived (int I, int j, int k): Base2(i), Base1(j) { c = k;  cout <<“Constructing Derived”;  }
~ Derived ( ) {  cout << Destructing Derived “;  } Void show( ) {  cout <<“1.”<<a<<“ 2.”<<b <<“ 3.”<<c;  } }; Int main ( ) {  Clrscr(); Derived ob(14,15,16); Ob.show(); } ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Virtual Base class Example  Class Base  {  public : int a ; }; Class D1 : public Base   D1 inherits Base {  public : int b ; }; Class D2 : public Base   D2 inherits Base {  public : int c ; }; Class D3 : public D1, public D2  D3 inherits D1 and D2 {  public :  int total; }; Void main ( ) { D3 ob; ob.a = 25  this is ambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“”<< ob.b<<“”<< ob.c<<“”<< ob.total<<“”<<“”; }
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Remedy
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Void main ( ) { D3 ob; ob.a = 25   now unambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“”<< ob.b<<“”<< ob.c<<“”<< ob.total<<“”<<“”; }
Example of Multilevel Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
class test: public student {   protected:   float sub1;   float sub2;   public:   void getmarks()   {   cout<<&quot;enter the marks of sub1,sub2&quot;;   cin>>sub1>>sub2;   }   void putmarks()   {   cout<<&quot;marks in sub1=&quot;<<sub1;   cout<<&quot;marks in sub2=&quot;<<sub2;   } };
class result : public test {   float total;   public:   void display(void)   {    total=sub1+sub2;   putnumber();   putmarks();   cout<<&quot;Total&quot;<<total;   }   };   void main()   {   result a;   a.get_number();   a.getmarks();   a.display();   }
  ANY QUERY   THANK YOU

More Related Content

What's hot

inheritance c++
inheritance c++inheritance c++
inheritance c++
Muraleedhar Sundararajan
 
Inheritance
InheritanceInheritance
Inheritance
Pranali Chaudhari
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
Vineeta Garg
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
Nivegeetha
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Laxman Puri
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
Arslan Waseem
 
Method overriding
Method overridingMethod overriding
Method overriding
Azaz Maverick
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
MASQ Technologies
 
Access specifier
Access specifierAccess specifier
Access specifier
zindadili
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
Rosie Jane Enomar
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
BhavyaJain137
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
Äkshäý M S
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
Sujan Mia
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
Sujan Mia
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
Pooja Jaiswal
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
Nilesh Dalvi
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
Arnab Bhaumik
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
RahulAnanda1
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Inheritance
InheritanceInheritance
InheritanceTech_MX
 

What's hot (20)

inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance, Object Oriented Programming
Inheritance, Object Oriented ProgrammingInheritance, Object Oriented Programming
Inheritance, Object Oriented Programming
 
Method overriding
Method overridingMethod overriding
Method overriding
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
Access specifier
Access specifierAccess specifier
Access specifier
 
Java Inheritance
Java InheritanceJava Inheritance
Java Inheritance
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
Single inheritance
Single inheritanceSingle inheritance
Single inheritance
 
Abstract class in c++
Abstract class in c++Abstract class in c++
Abstract class in c++
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 
Inheritance in JAVA PPT
Inheritance  in JAVA PPTInheritance  in JAVA PPT
Inheritance in JAVA PPT
 
Inheritance : Extending Classes
Inheritance : Extending ClassesInheritance : Extending Classes
Inheritance : Extending Classes
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
class and objects
class and objectsclass and objects
class and objects
 
Inheritance
InheritanceInheritance
Inheritance
 

Viewers also liked

Inheritance
InheritanceInheritance
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
 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
Shrija Madhu
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
Abhishek Pratap
 
Multi level hierarchy
Multi level hierarchyMulti level hierarchy
Multi level hierarchymyrajendra
 
Genetics pedigree problems
Genetics pedigree problemsGenetics pedigree problems
Genetics pedigree problems
callr
 
Basis of Genetic Inheritance
Basis of Genetic InheritanceBasis of Genetic Inheritance
Basis of Genetic Inheritance
Tean Zaheer
 
Pedigree analysis
Pedigree analysisPedigree analysis
Pedigree analysisAmy Allen
 
Inheritance
InheritanceInheritance
Inheritance
Hajar Len
 
pedigree analysis
 pedigree analysis pedigree analysis
pedigree analysis
Manyam kanaka valli
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
Salahaddin University-Erbil
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
Sachin Sharma
 
Patterns of Inheritance
Patterns of InheritancePatterns of Inheritance
Patterns of Inheritance
Lumen Learning
 

Viewers also liked (20)

Inheritance
InheritanceInheritance
Inheritance
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
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...
 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
 
Hybrid Inheritance in C++
Hybrid Inheritance in C++Hybrid Inheritance in C++
Hybrid Inheritance in C++
 
Multi level hierarchy
Multi level hierarchyMulti level hierarchy
Multi level hierarchy
 
Genetics pedigree problems
Genetics pedigree problemsGenetics pedigree problems
Genetics pedigree problems
 
Basis of Genetic Inheritance
Basis of Genetic InheritanceBasis of Genetic Inheritance
Basis of Genetic Inheritance
 
Pedigree Basics!
Pedigree Basics!Pedigree Basics!
Pedigree Basics!
 
Pedigree analysis
Pedigree analysisPedigree analysis
Pedigree analysis
 
THE LAWS OF MENDEL
THE LAWS OF MENDELTHE LAWS OF MENDEL
THE LAWS OF MENDEL
 
Inheritance
InheritanceInheritance
Inheritance
 
pedigree analysis
 pedigree analysis pedigree analysis
pedigree analysis
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Basic concepts of object oriented programming
Basic concepts of object oriented programmingBasic concepts of object oriented programming
Basic concepts of object oriented programming
 
Patterns of Inheritance
Patterns of InheritancePatterns of Inheritance
Patterns of Inheritance
 

Similar to Inheritance

inhertance c++
inhertance c++inhertance c++
inhertance c++
abhilashagupta
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdf
AneesAbbasi14
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
Muhammad Hammad Waseem
 
MODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computerMODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computer
ssuser6f3c8a
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
Amritsinghmehra
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
urvashipundir04
 
Lab3
Lab3Lab3
Inheritance
InheritanceInheritance
Inheritance
Burhan Ahmed
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
RutujaTandalwade
 
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++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphismFALLEE31188
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
RAJ KUMAR
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
study material
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
LadallaRajKumar
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
Shweta Shah
 
Inheritance
InheritanceInheritance
Inheritance
SangeethaSasi1
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
NAGASURESH MANOHARAN
 
Lecture 5 Inheritance
Lecture 5 InheritanceLecture 5 Inheritance
Lecture 5 Inheritancebunnykhan
 
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Abu Saleh
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
SudhanshuVijay3
 

Similar to Inheritance (20)

inhertance c++
inhertance c++inhertance c++
inhertance c++
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdf
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
 
MODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computerMODULE2_INHERITANCE_SESSION1.ppt computer
MODULE2_INHERITANCE_SESSION1.ppt computer
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
 
Lab3
Lab3Lab3
Lab3
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
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++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
11 Inheritance.ppt
11 Inheritance.ppt11 Inheritance.ppt
11 Inheritance.ppt
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
Lecture 5 Inheritance
Lecture 5 InheritanceLecture 5 Inheritance
Lecture 5 Inheritance
 
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16Lecture 6, c++(complete reference,herbet sheidt)chapter-16
Lecture 6, c++(complete reference,herbet sheidt)chapter-16
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
 

More from poonam.rwalia

Software Engineering
Software EngineeringSoftware Engineering
Software Engineeringpoonam.rwalia
 
Benefits Of Computer Software
Benefits Of Computer SoftwareBenefits Of Computer Software
Benefits Of Computer Software
poonam.rwalia
 
Internet
InternetInternet
Internet
poonam.rwalia
 

More from poonam.rwalia (7)

1 D Arrays in C++
1 D Arrays in C++1 D Arrays in C++
1 D Arrays in C++
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
Computer Ethics
Computer EthicsComputer Ethics
Computer Ethics
 
IT
ITIT
IT
 
Benefits Of Computer Software
Benefits Of Computer SoftwareBenefits Of Computer Software
Benefits Of Computer Software
 
Internet
InternetInternet
Internet
 
GIS
GISGIS
GIS
 

Recently uploaded

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

Inheritance

  • 2.
  • 3.
  • 4.
  • 5. When a derived class inherit from multiple base classes it is known as multiple Inheritance. A B C MULTIPLE INHERITANCE Base Class Derived Class
  • 6.
  • 7.
  • 8.
  • 9. A general form to defining a derived class is: Class derived class name: visibility mode base class name { members of derived class } ; Class ABC: public XYZ { members of ABC }; DEFINING DERIVED CLASS
  • 10. Example of derived class definition is: Class Sub : public Super public derivation { ……… members of sub }; Class Sub: private Super private derivation { …… ... members of sub }; Class Sub: protected Super protected derivation { …… ... members of sub };
  • 11. MULTIPLE INHERITANCE Example of derived class definition is: Class derived_class : vis_mode base1, vis_mode base 2 { ………… . members of derived class }; Class Sub : public SuperA, private SuperB { ……… members of sub };
  • 12.
  • 13. Private Visibility Mode- The public and protected members of the base class become private members of the derived class. The inherited members can only be accessed only through the member function of derived class. Protected Visibility Mode- The public and protected members of base class become protected members of the derived class.
  • 14. Visibility of Inherited base class members in Derived Class. Visibility Mode Public members of base class becomes Protected members of base class becomes Private members of the base class is not accessible to the derived class. Public Public Protected Protected Protected Protected Private Private Private
  • 15. Accessibility of Base class members No No Yes Private No Yes Yes Protected Yes Yes Yes Public Accessible from objects outside class Accessible from derived class Accessible from own class Access Specifier
  • 16.
  • 17. Class super { …… . }; Class Sub : public Super { ….. }; int main() { sub ob1; …… . }
  • 18.
  • 19. Class Base { int a; float b; public : Base(int I, float j) { a = i; b = j; } … }; Class Derived : public Base {…. Public : Derived ( int p, float q) : Base (p , q) { } }; Even if derived const does not need a parameter, yet it accepts parameter for base const.
  • 20. Class Base { int a; float b; public : Base( int i, float j) { a = i; b = j; } … }; Class Derived : public Base { int x; float y; Public : Derived ( int i, int j , int p, float q) : Base (p , q) { x = i ; Y = j ; } }; Derived Const is accepting parameter for itself( i ,j) and ( p , q) for Base const
  • 21.
  • 22. Class gamma: public beta, public alpha { int k; public: gamma(int a,float b, int c): alpha(a) , beta(b) { k=c; } void show() { cout<<“1”<<x<<“2”<<y<<“3”<<k; }}; void main() { gamma g(14,15.2,17); g.show(); }
  • 23.
  • 24.
  • 25.
  • 26. Abstract class A class that serves only as a base class from which other classes can be derived, but no objects of this base type exist, is known as abstract class.
  • 27.
  • 28. Class base2 { Protected : int b; public : Base2(int y) { b = y; cout<<“Constructing Base2”; } ~Base2 ( ) { cout<< Destructing Base2 “; } }; Class derived : public Base2, public Base1 { int c; public : derived (int I, int j, int k): Base2(i), Base1(j) { c = k; cout <<“Constructing Derived”; }
  • 29.
  • 30. Virtual Base class Example Class Base { public : int a ; }; Class D1 : public Base D1 inherits Base { public : int b ; }; Class D2 : public Base D2 inherits Base { public : int c ; }; Class D3 : public D1, public D2 D3 inherits D1 and D2 { public : int total; }; Void main ( ) { D3 ob; ob.a = 25 this is ambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“”<< ob.b<<“”<< ob.c<<“”<< ob.total<<“”<<“”; }
  • 31.
  • 32.
  • 33. Void main ( ) { D3 ob; ob.a = 25 now unambiguous Ob.b = 50; Ob.c = 75; Ob.total = ob.a +ob.b + ob.c; Cout <<ob.a<<“”<< ob.b<<“”<< ob.c<<“”<< ob.total<<“”<<“”; }
  • 34.
  • 35. class test: public student { protected: float sub1; float sub2; public: void getmarks() { cout<<&quot;enter the marks of sub1,sub2&quot;; cin>>sub1>>sub2; } void putmarks() { cout<<&quot;marks in sub1=&quot;<<sub1; cout<<&quot;marks in sub2=&quot;<<sub2; } };
  • 36. class result : public test { float total; public: void display(void) { total=sub1+sub2; putnumber(); putmarks(); cout<<&quot;Total&quot;<<total; } }; void main() { result a; a.get_number(); a.getmarks(); a.display(); }
  • 37. ANY QUERY THANK YOU