SlideShare uma empresa Scribd logo
1 de 16
Shree Swami Atmanand Saraswati
Institute Of Technology
Presentation Topic:- Concept Of Inheritance
Prepared By :-
Kachariya Parth S. (150760107026)
Katharotiya Pratik K. (150760107028)
Kidecha Rahul M. (150760107031)
Parmar Jay V. (150760107042)
Guided By :-
Prof. Vrutti D. Shah
Content
1. Concept Of Inheritance
2. Types Of Inheritance
i. Single Inheritance
ii. Multiple Inheritance
iii. Multi-Level Inheritance
What Is Inheritance ?
• Inheritance is a feature in Object Oriented
Programming.
• It can be described as a process of creating new
classes from existing classes.
• New classes inherit some of the properties and
behaviour of the existing classes.
• An existing class that is "parent" of a new class is
called a base class. New class that inherits
properties of the base class is called a derived
class.
• Inheritance is a technique of code reuse.
• It also provides possibility to extend existing
classes by creating derived classes.
• To Inherit a single base class the syntax is as follows :
Syntax :- class new_classname : visibility_mode base_classname
• To Inherit more than one base class the syntax is as follows :
Syntax :- class new_classname : visibility_mode base_class_1_name ,
visibility_mode base_class_2_name ,
visibility_mode base_class_n_name
• It can be defined as which mode we want to inherit the base class.
• It consist of three modes
– Protected
– Private
– Public
Visibility Mode
Base Class Derived Class
Visibility
Public
Derivation
Private
Derivation
Protected
Derivation
Private Not inherited Not inherited Not inherited
Protected Protected Private Protected
Public Public Private Protected
Types Of Inheritance
• Now, the concept of inheriting and creating the derived class can be done by
several techniques.
• If a Class is derived from a single class then it is Single Inheritance.
• Class B is Derived From Class A as per the below example is called single
inheritance.
Single Inheritance
( Example Of Single Inheritance )
#include<iostream>
using namespace std;
class A
{
public:
void displayA()
{
cout<<“Display Class A”<<endl;
}
};
class B : public A //Class B Is Derived from Class A
{
public:
void displayB()
{
cout<<“Display Class B”<<endl;
}
};
Example
int main()
{
B b;
b.displayA();
b.displayB();
return 0;
}
OUTPUT :
Display Class A
Display Class B
• If a Class is derived from a class which is derived from another class then it is
Multi-Level Inheritance.
• Class C is Derived From Class B and Class B is derived from Class A as per the
below example is called Multi-Level inheritance.
Multi-Level Inheritance
( Example Of Multi-Level Inheritance )
#include<iostream>
using namespace std;
class A
{
public:
void displayA()
{
cout<<“Display Class A”<<endl;
}
};
class B : public A //Class B is derived
{ from Class A
public:
void displayB()
{
cout<<“Display Class B”<<endl;
}
};
Example
class C: public B //Class C Is Derived
{ from Class B
public:
void displayC()
{
cout<<“Display Class C”<<endl;
}
};
OUTPUT :
Display Class A
Display Class B
Display Class C
Display Class A
Display Class B
int main()
{
C c;
c.displayA();
c.displayB();
c,displayC();
B b;
b.displayA();
b.displayB();
b.displayC(); // Object of Class B can not call The return
0; function of Class C
}
• If a Class is derived from more than one class then it is a Multiple Inheritance.
• Class C is Derived From Class A and Class B as per the below example is called Multiple
Inheritance.
Multiple Inheritance
( Example Of Multiple Inheritance )
#include<iostream>
using namespace std;
class A
{
public:
void displayA()
{
cout<<“Display Class A”<<endl;
}
};
class B
{
public:
void displayB()
{
cout<<“Display Class B”<<endl;
}
};
Example
class C: public A, public B //Class C Is Derived
{ from Class A
public: and Class B
void displayC()
{
cout<<“Display Class C”<<endl;
}
};
int main()
{
C c;
c.displayA();
c.displayB();
c,displayC();
return 0;
}
OUTPUT :
Display Class A
Display Class B
Display Class C
Example
#include<iostream>
using namespace std;
class A
{
int a;
public:
void getdata();
{
cin>>a;
}
int get_a()
{
return a;
}
};
class B
{
int b;
public:
void getdata1()
{
cin>>b;
}
int get_b()
{
return b;
}
};
class C : public A, public B //Class C Is Derived from Class A and Class B
{
int c;
public:
void mult()
{
c=get_a()*get_b();
cout<<c<<endl;
}
};
main()
{
C p;
p.getdata();
p.getdata1();
p.mult();
}
OUTPUT :
2
5
10
Oopc (group 9)

Mais conteúdo relacionado

Mais procurados (20)

Inheritance in C++
Inheritance in C++Inheritance in C++
Inheritance in C++
 
inheritance
inheritanceinheritance
inheritance
 
EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++EASY TO LEARN INHERITANCE IN C++
EASY TO LEARN INHERITANCE IN C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance in OOPS
Inheritance in OOPSInheritance in OOPS
Inheritance in OOPS
 
Inheritance in c++
Inheritance in c++Inheritance in c++
Inheritance in c++
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
04. Review OOP with Java
04. Review OOP with Java04. Review OOP with Java
04. Review OOP with Java
 
Inheritance ppt
Inheritance pptInheritance ppt
Inheritance ppt
 
C# Inheritance
C# InheritanceC# Inheritance
C# Inheritance
 
Classes and Objects in C#
Classes and Objects in C#Classes and Objects in C#
Classes and Objects in C#
 
Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.Inheritance OOP Concept in C++.
Inheritance OOP Concept in C++.
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4INHERITANCE-Oopc ppt-ta4
INHERITANCE-Oopc ppt-ta4
 
Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.Presentation on class and object in Object Oriented programming.
Presentation on class and object in Object Oriented programming.
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
OOP C++
OOP C++OOP C++
OOP C++
 
Inheritance C#
Inheritance C#Inheritance C#
Inheritance C#
 
6 Inheritance
6 Inheritance6 Inheritance
6 Inheritance
 

Semelhante a Oopc (group 9)

oop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdfoop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdfitxminahil29
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxDeepasCSE
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfkshitijsaini9
 
Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Abhishek Khune
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdfstudy material
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdfAneesAbbasi14
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPTkishu0005
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingNithyaN19
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interfaceShubham Sharma
 
02-OOP with Java.ppt
02-OOP with Java.ppt02-OOP with Java.ppt
02-OOP with Java.pptEmanAsem4
 

Semelhante a Oopc (group 9) (20)

oop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdfoop database doc for studevsgdy fdsyn hdf
oop database doc for studevsgdy fdsyn hdf
 
Inheritance and Interfaces
Inheritance and InterfacesInheritance and Interfaces
Inheritance and Interfaces
 
Inheritance
InheritanceInheritance
Inheritance
 
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptxINHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
INHERITANCE, POINTERS, VIRTUAL FUNCTIONS, POLYMORPHISM.pptx
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
Inheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdfInheritance_abstractclass_interface.pdf
Inheritance_abstractclass_interface.pdf
 
Java
JavaJava
Java
 
Inheritance.pptx
Inheritance.pptxInheritance.pptx
Inheritance.pptx
 
Chap-3 Inheritance.pptx
Chap-3 Inheritance.pptxChap-3 Inheritance.pptx
Chap-3 Inheritance.pptx
 
Inheritance
InheritanceInheritance
Inheritance
 
Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)Lecture 14 (inheritance basics)
Lecture 14 (inheritance basics)
 
chapter-10-inheritance.pdf
chapter-10-inheritance.pdfchapter-10-inheritance.pdf
chapter-10-inheritance.pdf
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
 
lecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdflecture-2021inheritance-160705095417.pdf
lecture-2021inheritance-160705095417.pdf
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Inheritance
InheritanceInheritance
Inheritance
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Inheritance and interface
Inheritance and interfaceInheritance and interface
Inheritance and interface
 
02-OOP with Java.ppt
02-OOP with Java.ppt02-OOP with Java.ppt
02-OOP with Java.ppt
 

Último

2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...OnePlan Solutions
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 

Último (20)

2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
Tech Tuesday Slides - Introduction to Project Management with OnePlan's Work ...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 

Oopc (group 9)

  • 1. Shree Swami Atmanand Saraswati Institute Of Technology Presentation Topic:- Concept Of Inheritance Prepared By :- Kachariya Parth S. (150760107026) Katharotiya Pratik K. (150760107028) Kidecha Rahul M. (150760107031) Parmar Jay V. (150760107042) Guided By :- Prof. Vrutti D. Shah
  • 2. Content 1. Concept Of Inheritance 2. Types Of Inheritance i. Single Inheritance ii. Multiple Inheritance iii. Multi-Level Inheritance
  • 3. What Is Inheritance ? • Inheritance is a feature in Object Oriented Programming. • It can be described as a process of creating new classes from existing classes. • New classes inherit some of the properties and behaviour of the existing classes. • An existing class that is "parent" of a new class is called a base class. New class that inherits properties of the base class is called a derived class. • Inheritance is a technique of code reuse. • It also provides possibility to extend existing classes by creating derived classes.
  • 4. • To Inherit a single base class the syntax is as follows : Syntax :- class new_classname : visibility_mode base_classname • To Inherit more than one base class the syntax is as follows : Syntax :- class new_classname : visibility_mode base_class_1_name , visibility_mode base_class_2_name , visibility_mode base_class_n_name
  • 5. • It can be defined as which mode we want to inherit the base class. • It consist of three modes – Protected – Private – Public Visibility Mode Base Class Derived Class Visibility Public Derivation Private Derivation Protected Derivation Private Not inherited Not inherited Not inherited Protected Protected Private Protected Public Public Private Protected
  • 6. Types Of Inheritance • Now, the concept of inheriting and creating the derived class can be done by several techniques.
  • 7. • If a Class is derived from a single class then it is Single Inheritance. • Class B is Derived From Class A as per the below example is called single inheritance. Single Inheritance ( Example Of Single Inheritance )
  • 8. #include<iostream> using namespace std; class A { public: void displayA() { cout<<“Display Class A”<<endl; } }; class B : public A //Class B Is Derived from Class A { public: void displayB() { cout<<“Display Class B”<<endl; } }; Example int main() { B b; b.displayA(); b.displayB(); return 0; } OUTPUT : Display Class A Display Class B
  • 9. • If a Class is derived from a class which is derived from another class then it is Multi-Level Inheritance. • Class C is Derived From Class B and Class B is derived from Class A as per the below example is called Multi-Level inheritance. Multi-Level Inheritance ( Example Of Multi-Level Inheritance )
  • 10. #include<iostream> using namespace std; class A { public: void displayA() { cout<<“Display Class A”<<endl; } }; class B : public A //Class B is derived { from Class A public: void displayB() { cout<<“Display Class B”<<endl; } }; Example class C: public B //Class C Is Derived { from Class B public: void displayC() { cout<<“Display Class C”<<endl; } };
  • 11. OUTPUT : Display Class A Display Class B Display Class C Display Class A Display Class B int main() { C c; c.displayA(); c.displayB(); c,displayC(); B b; b.displayA(); b.displayB(); b.displayC(); // Object of Class B can not call The return 0; function of Class C }
  • 12. • If a Class is derived from more than one class then it is a Multiple Inheritance. • Class C is Derived From Class A and Class B as per the below example is called Multiple Inheritance. Multiple Inheritance ( Example Of Multiple Inheritance )
  • 13. #include<iostream> using namespace std; class A { public: void displayA() { cout<<“Display Class A”<<endl; } }; class B { public: void displayB() { cout<<“Display Class B”<<endl; } }; Example class C: public A, public B //Class C Is Derived { from Class A public: and Class B void displayC() { cout<<“Display Class C”<<endl; } }; int main() { C c; c.displayA(); c.displayB(); c,displayC(); return 0; } OUTPUT : Display Class A Display Class B Display Class C
  • 14. Example #include<iostream> using namespace std; class A { int a; public: void getdata(); { cin>>a; } int get_a() { return a; } }; class B { int b; public: void getdata1() { cin>>b; } int get_b() { return b; } };
  • 15. class C : public A, public B //Class C Is Derived from Class A and Class B { int c; public: void mult() { c=get_a()*get_b(); cout<<c<<endl; } }; main() { C p; p.getdata(); p.getdata1(); p.mult(); } OUTPUT : 2 5 10