SlideShare una empresa de Scribd logo
1 de 30
OJECT
ORINTED
PROGRAMMING
IN
C++.
IN THE OOPS WE WILL PERFORMS VARIOUS
COMPONENTS.
1)CLASS
2)OBJECT
3)ABSTRACT
4)ENCAPCULATION
5)INHERITANCE
CLASS
Class is a collection of member data and
member function.
Member data is a collection of attribute
in a class.
Member function is a collection of
operation .It is perform in the class.
SYNTAX OF CLASS
Class classname
{
Private:
All member data
Public:
All member function
};
EXAMPLE OF CLASS WITH THE
HELP OF SUM OPERATION
#include<conio.h>
#include<iostream.h>
Class sum
{
Private:
int a,b,c;
Public:
void input()
{
Cout<<“enter the value of a and b variable”;
Cin>>a>>b;
}
Void display()
{
C=a+b;
Cout<<“value of sun is”<<c;
}
};
Void main()
{
Sum s;
Clrscr();
s.input();
s.output();
Getch();
}
OBJECT OBJECT
Object is a real entity world. With the help of OBJECT
we can call the member data and member function.
It is just like a membership.
Syntax of object:
class name classobject;
Classobject.mamber function();
EXAMPLE OF CLASS AND OBJECT WITH THE
HELP OF SUM OPERATION
#include<conio.h>
#include<iostream.h>
Class sum
{
Private:
int a,b,c;
Public:
void input()
{
Cout<<“enter the value of a and b variable”;
Cin>>a>>b;
}
Void display()
{
C=a+b;
Cout<<“value of sun is”<<c;
}
};
Void main()
{
Sum s; // Here (s) is a object . It is calling the member data and member
function.
Clrscr();
s.input();
s.output();
Getch();
}
ABSTRACT
An abstract class is, conceptually, a class that cannot be
instantiated and is usually implemented as a class that
has one or more pure virtual (abstract) functions.
pure virtual function is one which must be overridden
by any concrete (i.e., non-abstract) derived class. This
is indicated in the declaration with the syntax " = 0" in
the member function's declaration.
ENCAPCULATION
Encapsulation is the packing of data and functions into a
single component. The features of encapsulation are
supported using classes in most object-oriented
programming languages, although other alternatives
also exist. It allows selective hiding of properties and
methods in an object by building an impenetrable wall
to protect the code from accidental corruption.
Best example of Encapsulations is class because it have
the multiple of member data and member function in
the same class.
INHERITANCE
With the help of inheritance we can reuse the data one
class to anther class .
Which have inherits the properties of base class is
known as parents class/base class/super class.
Which have inherits the properties of parents class is
known as sub class/child class/inherit class.
Inheritance seprate into many class…
1) Single Inheritance 4) Hybrid Inheritance
2) Hierarchical Inheritance 5) c
3) Multi Level Inheritance
Single Inheritance
when a single derived class is created from a single base
class then the inheritance is called as single
inheritance.
BASE CLASS
DERIVED
CLASS
It is known as single
inheritance class.
SYNTAX OF SINGLE INHERITANCE
class a
{
Public:
all member data;
Public:
all member function;
};
class b:public a
{
Public:
all member data;
Public:
all member function;
};
EXAMPLE OF SINGLE INHERITANCE
#include<iostream.h>
#include<conio.h>
Class sum
{
Public:
Int a=5,b=5,c;
Public:
void display()
{
c=a+b;
cout<<“value of sum is”<<c;
}
};
class sub: public sum
{
Public:
Int d;
Public:
void output()
{
d=a-b;
cout<<“the value of subtraction is”<<d;
}
};
void main()
{
clrscr();
sub s;
s.display();
s.output();
getch();
}
Hierarchical Inheritance
when more than one derived class are created from a
single base class, then that inheritance is called as
hierarchical inheritance.
BASE CLASS
DERIVED CLASS (2)DERIVED CLASS (1)
SYNTAX OF HIEARCHICAL INHERITANCE
Class a
{
Public: all member data;
Public: all member function;
};
Class b:public a
{
Public: all member data;
Public: all member function;
};
Class c:public a
{
Private: all member data;
Public: all member function;
};
EXAMPLE OF HIARCHICAL
INHERITANCE
#include<conio.h>
#include<iostream.h>
Class a
{
public :
int a=10,b=2,c,d,e;
Public:
void output()
{
c=a-b;
Cout<<“value of sum is”<<c;
}
};
class b:public a
{
Public:
void display()
{
d=a-b;
Cout<<“value of subtraction is;
Cout<<d;
}
};
Class c:public
{
Public:
void coutput()
{
e=a*b;
Cout<<“multiplication is”<<e;
}
};
void main()
{
Clrscr();
a l;
l.output();
l.display();
l.coutput();
getch();
}
Multi Level Inheritance
when a derived class is created from another derived
class, then that inheritance is called as multi level
inheritance.
BASE CLASS
DERIVED
CLASS (1)
DEEIVED
CLASS(2)
SYNTAX OF MULTILEVEL INHERITANCE
Class a
{
Public: all member data;
Public: all member
function;
};
Class b:public a
{
Public:all member data;
Public:all member
function;
};
Class c:public c
{
Private:all member data;
Private:all member
function;
};
Hybrid Inheritance
Hybrid inheritance is combination of two or more
inheritances such as single,multiple,multilevel or
Hierarchical inheritances.
DREVIED CLASS(1)
DERIVED CLASS(3)
DERIVED CLASS(2)
BASE CLASS
SYNTAX OF HYBRID INHERITANCE
Class a
{
Public:all member data;
Public:all member function;
};
Class b:public a
{
Public:all member data;
Public:all member function;
};
Class c:public c
{
Public:all member data;
Public:all member function;
};
Class d:public d
{
Public:all member data;
Public:all member function;
};
Multiple Inheritance
Deriving directly from more than one class is usually
called multiple inheritance.
BASE CLASS
DERVIED
CLASS(1)
DERIVED CLASS(3)
DERIVED
CLASS (2)
DERIVED
CLASS(4)
SYNTAX OF MULTIPLE INHERITANCE
Class a
{
Public:all memberdata;
Public:all member function;
};
Class b:public a
{
Public:all memberdata;
Public:all member function;
};
Class c:public a
{
Public:all memberdata;
Public:all member function;
};
Class d:public b
{
Public:all memberdata;
Public:all member function;
};
Class e:public c,public d
{
Private:all member data;
Public:all member
function;
};www,cpd-india.com

Más contenido relacionado

La actualidad más candente

Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
Alok Kumar
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
thinkphp
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 

La actualidad más candente (20)

inheritance c++
inheritance c++inheritance c++
inheritance c++
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
Polymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh SarkarPolymorphism in Java by Animesh Sarkar
Polymorphism in Java by Animesh Sarkar
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
Class and object in c++
Class and object in c++Class and object in c++
Class and object in c++
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Function overloading
Function overloadingFunction overloading
Function overloading
 
Python-Polymorphism.pptx
Python-Polymorphism.pptxPython-Polymorphism.pptx
Python-Polymorphism.pptx
 
Polymorphism
PolymorphismPolymorphism
Polymorphism
 
Class and object in C++
Class and object in C++Class and object in C++
Class and object in C++
 
Polymorphism In c++
Polymorphism In c++Polymorphism In c++
Polymorphism In c++
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
concept of oops
concept of oopsconcept of oops
concept of oops
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
07. Virtual Functions
07. Virtual Functions07. Virtual Functions
07. Virtual Functions
 
OOPs in Java
OOPs in JavaOOPs in Java
OOPs in Java
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 

Destacado

Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
Harit Kothari
 

Destacado (20)

Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
Php Training Session 4
Php Training Session 4Php Training Session 4
Php Training Session 4
 
Lecture09
Lecture09Lecture09
Lecture09
 
Andrealozada
AndrealozadaAndrealozada
Andrealozada
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
 
Oop
OopOop
Oop
 
Inheritance
InheritanceInheritance
Inheritance
 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
 
Session Management & Cookies In Php
Session Management & Cookies In PhpSession Management & Cookies In Php
Session Management & Cookies In Php
 
Inheritance
InheritanceInheritance
Inheritance
 
Trees
TreesTrees
Trees
 
EEE 3rd year oops cat 3 ans
EEE 3rd year  oops cat 3  ansEEE 3rd year  oops cat 3  ans
EEE 3rd year oops cat 3 ans
 
Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)Programming Fundamentals With OOPs Concepts (Java Examples Based)
Programming Fundamentals With OOPs Concepts (Java Examples Based)
 
EEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answerEEE oops Vth semester viva questions with answer
EEE oops Vth semester viva questions with answer
 
Es272 ch4b
Es272 ch4bEs272 ch4b
Es272 ch4b
 
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
M.TECH 1ST SEM COMPUTER SCIENCE AOS LAB PRGMS 2014
 
Viva questions
Viva questions Viva questions
Viva questions
 
inline function
inline function inline function
inline function
 

Similar a OOPS IN C++

Unit3 java
Unit3 javaUnit3 java
Unit3 java
mrecedu
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
DeepasCSE
 

Similar a OOPS IN C++ (20)

Ppt of c++ vs c#
Ppt of c++ vs c#Ppt of c++ vs c#
Ppt of c++ vs c#
 
Multiple Inheritance
Multiple InheritanceMultiple Inheritance
Multiple Inheritance
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Opp concept in c++
Opp concept in c++Opp concept in c++
Opp concept in c++
 
inheritance in OOPM
inheritance in OOPMinheritance in OOPM
inheritance in OOPM
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Introduction to object oriented programming concepts
Introduction to object oriented programming conceptsIntroduction to object oriented programming concepts
Introduction to object oriented programming concepts
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
10 inheritance
10 inheritance10 inheritance
10 inheritance
 
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptxinheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
 
Unit3 java
Unit3 javaUnit3 java
Unit3 java
 
Inheritance
InheritanceInheritance
Inheritance
 
C++ presentation
C++ presentationC++ presentation
C++ presentation
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

OOPS IN C++

  • 2. IN THE OOPS WE WILL PERFORMS VARIOUS COMPONENTS. 1)CLASS 2)OBJECT 3)ABSTRACT 4)ENCAPCULATION 5)INHERITANCE
  • 3. CLASS Class is a collection of member data and member function. Member data is a collection of attribute in a class. Member function is a collection of operation .It is perform in the class.
  • 4. SYNTAX OF CLASS Class classname { Private: All member data Public: All member function };
  • 5. EXAMPLE OF CLASS WITH THE HELP OF SUM OPERATION #include<conio.h> #include<iostream.h> Class sum { Private: int a,b,c; Public: void input() { Cout<<“enter the value of a and b variable”; Cin>>a>>b; }
  • 6. Void display() { C=a+b; Cout<<“value of sun is”<<c; } }; Void main() { Sum s; Clrscr(); s.input(); s.output(); Getch(); }
  • 7. OBJECT OBJECT Object is a real entity world. With the help of OBJECT we can call the member data and member function. It is just like a membership. Syntax of object: class name classobject; Classobject.mamber function();
  • 8. EXAMPLE OF CLASS AND OBJECT WITH THE HELP OF SUM OPERATION #include<conio.h> #include<iostream.h> Class sum { Private: int a,b,c; Public: void input() { Cout<<“enter the value of a and b variable”; Cin>>a>>b; }
  • 9. Void display() { C=a+b; Cout<<“value of sun is”<<c; } }; Void main() { Sum s; // Here (s) is a object . It is calling the member data and member function. Clrscr(); s.input(); s.output(); Getch(); }
  • 10. ABSTRACT An abstract class is, conceptually, a class that cannot be instantiated and is usually implemented as a class that has one or more pure virtual (abstract) functions. pure virtual function is one which must be overridden by any concrete (i.e., non-abstract) derived class. This is indicated in the declaration with the syntax " = 0" in the member function's declaration.
  • 11. ENCAPCULATION Encapsulation is the packing of data and functions into a single component. The features of encapsulation are supported using classes in most object-oriented programming languages, although other alternatives also exist. It allows selective hiding of properties and methods in an object by building an impenetrable wall to protect the code from accidental corruption. Best example of Encapsulations is class because it have the multiple of member data and member function in the same class.
  • 12. INHERITANCE With the help of inheritance we can reuse the data one class to anther class . Which have inherits the properties of base class is known as parents class/base class/super class. Which have inherits the properties of parents class is known as sub class/child class/inherit class. Inheritance seprate into many class… 1) Single Inheritance 4) Hybrid Inheritance 2) Hierarchical Inheritance 5) c 3) Multi Level Inheritance
  • 13. Single Inheritance when a single derived class is created from a single base class then the inheritance is called as single inheritance. BASE CLASS DERIVED CLASS It is known as single inheritance class.
  • 14. SYNTAX OF SINGLE INHERITANCE class a { Public: all member data; Public: all member function; }; class b:public a { Public: all member data; Public: all member function; };
  • 15. EXAMPLE OF SINGLE INHERITANCE #include<iostream.h> #include<conio.h> Class sum { Public: Int a=5,b=5,c; Public: void display() { c=a+b;
  • 16. cout<<“value of sum is”<<c; } }; class sub: public sum { Public: Int d; Public: void output()
  • 17. { d=a-b; cout<<“the value of subtraction is”<<d; } }; void main() { clrscr(); sub s; s.display(); s.output(); getch(); }
  • 18. Hierarchical Inheritance when more than one derived class are created from a single base class, then that inheritance is called as hierarchical inheritance. BASE CLASS DERIVED CLASS (2)DERIVED CLASS (1)
  • 19. SYNTAX OF HIEARCHICAL INHERITANCE Class a { Public: all member data; Public: all member function; }; Class b:public a { Public: all member data; Public: all member function; };
  • 20. Class c:public a { Private: all member data; Public: all member function; };
  • 21. EXAMPLE OF HIARCHICAL INHERITANCE #include<conio.h> #include<iostream.h> Class a { public : int a=10,b=2,c,d,e; Public: void output() { c=a-b; Cout<<“value of sum is”<<c; } }; class b:public a { Public: void display() {
  • 22. d=a-b; Cout<<“value of subtraction is; Cout<<d; } }; Class c:public { Public: void coutput() { e=a*b; Cout<<“multiplication is”<<e; } }; void main() { Clrscr(); a l; l.output();
  • 24. Multi Level Inheritance when a derived class is created from another derived class, then that inheritance is called as multi level inheritance. BASE CLASS DERIVED CLASS (1) DEEIVED CLASS(2)
  • 25. SYNTAX OF MULTILEVEL INHERITANCE Class a { Public: all member data; Public: all member function; }; Class b:public a { Public:all member data; Public:all member function; }; Class c:public c { Private:all member data; Private:all member function; };
  • 26. Hybrid Inheritance Hybrid inheritance is combination of two or more inheritances such as single,multiple,multilevel or Hierarchical inheritances. DREVIED CLASS(1) DERIVED CLASS(3) DERIVED CLASS(2) BASE CLASS
  • 27. SYNTAX OF HYBRID INHERITANCE Class a { Public:all member data; Public:all member function; }; Class b:public a { Public:all member data; Public:all member function; }; Class c:public c { Public:all member data; Public:all member function; }; Class d:public d { Public:all member data; Public:all member function; };
  • 28. Multiple Inheritance Deriving directly from more than one class is usually called multiple inheritance. BASE CLASS DERVIED CLASS(1) DERIVED CLASS(3) DERIVED CLASS (2) DERIVED CLASS(4)
  • 29. SYNTAX OF MULTIPLE INHERITANCE Class a { Public:all memberdata; Public:all member function; }; Class b:public a { Public:all memberdata; Public:all member function; }; Class c:public a { Public:all memberdata; Public:all member function; }; Class d:public b { Public:all memberdata; Public:all member function; };
  • 30. Class e:public c,public d { Private:all member data; Public:all member function; };www,cpd-india.com