SlideShare a Scribd company logo
Types of Inheritance:
Single Inheritance.
Multilevel Inheritance
Multiple Inheritance.
Hierarchical Inheritance.
Hybrid Inheritance.
Single Inheritance:
Example:
#include<iostream>
using namespace std;
class dox
{
int a;
public:
int b,c;
dox();
~dox();
};
class box : public dox
{
public:
int x,y;
box();
void multi();
void add();
~box();
};
dox :: dox()
{ cout<<"enter a number:"<<endl;
cin>>a; }
dox::~dox()
{cout<<"number:"<<a<<endl; }
box :: box()
{ cout<<"enter two
number:"<<endl; cin>>b>>c; }
void box :: multi()
{ x=b*c; }
void box :: add()
{ y=b+c; }
box :: ~box()
{cout<<"multiply:"<<x<<endl;
cout<<"addition:"<<y<<endl; }
int main()
{ box j;
j.multi();
j.add();
return 0;
}
Multilevel Inheritance:
Example:
#include<iostream>
using namespace std;
class a
{
protected:
int d,i=20,j=2;
public:
void devided()
{
d=i/j;
}
};
class b : public a
{
protected: int x=33,y=2,z;
public:
void reminder()
{
devided();
z=x%y;
}
};
class c : public b
{
public:
void display()
{
cout<<"divided:"<<d<<endl;
cout<<"reminder:"<<z<<endl;
}
};
int main()
{
c n;
n.reminder();
n.display();
}
Multiple Inheritance:
Example:
#include<iostream>
using namespace std;
class x
{
protected :
int a;
public:
void get_age(){
cout<<"enter
age:"<<endl;
cin>>a;
}};
class y
{
protected :
int id;
public:
void get_id()
{ cout<<"enter Id:"<<endl;
cin>>id;
}};
class z :public x,public y
{
public:
void out()
{
cout<<"nid:"<<id<<"nage
"<<a<<endl; }};
int main()
{
z i;
i.get_age();
i.get_id();
i.out();
Return 0;
}
Hierarchical Inheritance:
Example:
#include<iostream>
using namespace std;
class A
{ public:
int a;
void getnumber()
{cout<<"nEnter
Number :";
cin>>a;
}};
class B : public A
{
public:
void square()
{getnumber();
cout<<"Square of the
number :"<<(a*a);
}};
class C :public A
{public:
void cube()
{getnumber();
cout<<"nCube of the
number :"<<(a*a*a);
}};
int main()
{
B b1;
b1.square();
C c1;
c1.cube();
}
Hybrid Inheritance:
Example:
#include<iostream>
using namespace std;
class A
{protected:
int s;
public:
void get_value()
{
cout<<"enter speaking
score:"<<endl;
cin>>s;}};
class B:public A
{
protected : int r;
public:
void in(){
cout<<"enter reading
score:"<<endl;
cin>>r;
}};
class C
{
protected: int w,l;
public:
Void put_value()
{cout<<"enter writing
score:"<<endl;
cin>>w;
cout<<"enter listening
score:"<<endl;
cin>>l;}};
class V:public C,public B
{
int avg,add;
public:
void out()
{
add=s+w+l+r;
avg=(s+w+l+r)/3;
cout<<"addition of the
scores:"<<add<<endl;
cout<<"average of the
scores:"<<avg<<endl;}};
int main()
{
V i;
i.get_value();
i.in();
i.put_value();
i.out();
return 0;
}
Oop

More Related Content

What's hot

Class & sub class
Class & sub classClass & sub class
Class & sub class
HSS-Software House
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
ujihisa
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
Parthipan Parthi
 
Kotlin, a nova linguagem oficial do Android
Kotlin, a nova linguagem oficial do AndroidKotlin, a nova linguagem oficial do Android
Kotlin, a nova linguagem oficial do Android
GDGFoz
 
Cryptography
CryptographyCryptography
Cryptography
gadgetic
 
C sharp 8.0 new features
C sharp 8.0 new featuresC sharp 8.0 new features
C sharp 8.0 new features
Miguel Bernard
 
RediSearch
RediSearchRediSearch
RediSearch
Dvir Volk
 
Funcd
FuncdFuncd
Searching Billions of Documents with Redis
Searching Billions of Documents with RedisSearching Billions of Documents with Redis
Searching Billions of Documents with Redis
Dvir Volk
 
Live in shell
Live in shellLive in shell
Live in shell
Tiến Nguyễn
 
.NET/C#_6
.NET/C#_6.NET/C#_6
.NET/C#_6
RaynaITSTEP
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference book
Anand Dhana
 
File Handling Program
File Handling ProgramFile Handling Program
ClusterDesktop Socks5 Proxy
ClusterDesktop Socks5 ProxyClusterDesktop Socks5 Proxy
ClusterDesktop Socks5 Proxy
Emil Parashkevov
 
メディアアートにおけるプログラミング言語Rubyの役割
メディアアートにおけるプログラミング言語Rubyの役割メディアアートにおけるプログラミング言語Rubyの役割
メディアアートにおけるプログラミング言語Rubyの役割
Koichiro Eto
 

What's hot (20)

1
11
1
 
Class & sub class
Class & sub classClass & sub class
Class & sub class
 
LLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, JapanLLVM Workshop Osaka Umeda, Japan
LLVM Workshop Osaka Umeda, Japan
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
 
Kotlin, a nova linguagem oficial do Android
Kotlin, a nova linguagem oficial do AndroidKotlin, a nova linguagem oficial do Android
Kotlin, a nova linguagem oficial do Android
 
Cryptography
CryptographyCryptography
Cryptography
 
C sharp 8.0 new features
C sharp 8.0 new featuresC sharp 8.0 new features
C sharp 8.0 new features
 
RediSearch
RediSearchRediSearch
RediSearch
 
Funcd
FuncdFuncd
Funcd
 
Searching Billions of Documents with Redis
Searching Billions of Documents with RedisSearching Billions of Documents with Redis
Searching Billions of Documents with Redis
 
Live in shell
Live in shellLive in shell
Live in shell
 
.NET/C#_6
.NET/C#_6.NET/C#_6
.NET/C#_6
 
Lecture20
Lecture20Lecture20
Lecture20
 
Go之道
Go之道Go之道
Go之道
 
vbscript-reference book
vbscript-reference bookvbscript-reference book
vbscript-reference book
 
P2
P2P2
P2
 
File Handling Program
File Handling ProgramFile Handling Program
File Handling Program
 
ClusterDesktop Socks5 Proxy
ClusterDesktop Socks5 ProxyClusterDesktop Socks5 Proxy
ClusterDesktop Socks5 Proxy
 
メディアアートにおけるプログラミング言語Rubyの役割
メディアアートにおけるプログラミング言語Rubyの役割メディアアートにおけるプログラミング言語Rubyの役割
メディアアートにおけるプログラミング言語Rubyの役割
 
Elf文件解析
Elf文件解析Elf文件解析
Elf文件解析
 

Viewers also liked

Andrealozada
AndrealozadaAndrealozada
Andrealozada
Andrea Lozada
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
Edhole.com
 
Inheritance
InheritanceInheritance
Inheritance
PriyankaAkhil
 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
Shrija Madhu
 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
tayyaba nawaz
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritanceharshaltambe
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss SeidelEric Davishahl
 
Gauss seidel
Gauss seidelGauss seidel
Gauss seidel
Ahmed M. Elkholy
 
Solución de sistemas de ecuaciones lineales.
Solución de sistemas de ecuaciones lineales. Solución de sistemas de ecuaciones lineales.
Solución de sistemas de ecuaciones lineales.
Alida Marleny Ros Medrano
 
Matemáticas II ecuaciones lineales
Matemáticas II   ecuaciones linealesMatemáticas II   ecuaciones lineales
Matemáticas II ecuaciones lineales
analaura_fdz
 
Jacobi and gauss-seidel
Jacobi and gauss-seidelJacobi and gauss-seidel
Jacobi and gauss-seidel
arunsmm
 
Load flow study
Load flow studyLoad flow study
Load flow study
f s
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
Amritsinghmehra
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
Boopathi K
 
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
 

Viewers also liked (20)

Andrealozada
AndrealozadaAndrealozada
Andrealozada
 
Admission in india 2015
Admission in india 2015Admission in india 2015
Admission in india 2015
 
Inheritance
InheritanceInheritance
Inheritance
 
Hierarchical inheritance
Hierarchical inheritanceHierarchical inheritance
Hierarchical inheritance
 
inheritance in C++
inheritance in C++inheritance in C++
inheritance in C++
 
Inheritance
InheritanceInheritance
Inheritance
 
Es272 ch4b
Es272 ch4bEs272 ch4b
Es272 ch4b
 
inheritance
inheritanceinheritance
inheritance
 
C++ Multiple Inheritance
C++ Multiple InheritanceC++ Multiple Inheritance
C++ Multiple Inheritance
 
Linear Systems Gauss Seidel
Linear Systems   Gauss SeidelLinear Systems   Gauss Seidel
Linear Systems Gauss Seidel
 
Gauss seidel
Gauss seidelGauss seidel
Gauss seidel
 
Solución de sistemas de ecuaciones lineales.
Solución de sistemas de ecuaciones lineales. Solución de sistemas de ecuaciones lineales.
Solución de sistemas de ecuaciones lineales.
 
Matemáticas II ecuaciones lineales
Matemáticas II   ecuaciones linealesMatemáticas II   ecuaciones lineales
Matemáticas II ecuaciones lineales
 
Jacobi and gauss-seidel
Jacobi and gauss-seidelJacobi and gauss-seidel
Jacobi and gauss-seidel
 
Load flow study
Load flow studyLoad flow study
Load flow study
 
OOPS IN C++
OOPS IN C++OOPS IN C++
OOPS IN C++
 
C++ OOPS Concept
C++ OOPS ConceptC++ OOPS Concept
C++ OOPS Concept
 
Gauss sediel
Gauss sedielGauss sediel
Gauss sediel
 
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...
 

Similar to Oop

OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
Thooyavan Venkatachalam
 
C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)
Ananda Kumar HN
 
C++ practical
C++ practicalC++ practical
C++ practical
Rahul juneja
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
Jay Patel
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
Javier Gonzalez-Sanchez
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
Jan Rüegg
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
ssuser3cbb4c
 
C++ Language
C++ LanguageC++ Language
C++ Language
Vidyacenter
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler support
Syed Zaid Irshad
 
New presentation oop
New presentation oopNew presentation oop
New presentation oop
Ch shampi Ch shampi
 
C++ prgms 3rd unit
C++ prgms 3rd unitC++ prgms 3rd unit
C++ prgms 3rd unit
Ananda Kumar HN
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
Manusha Dilan
 
class object.pptx
class object.pptxclass object.pptx
class object.pptx
Killmekhilati
 
c++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfc++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdf
nisarmca
 
12
1212

Similar to Oop (20)

OOPS Basics With Example
OOPS Basics With ExampleOOPS Basics With Example
OOPS Basics With Example
 
Opp compile
Opp compileOpp compile
Opp compile
 
C++ programs
C++ programsC++ programs
C++ programs
 
C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)C++ prgms 5th unit (inheritance ii)
C++ prgms 5th unit (inheritance ii)
 
Oop1
Oop1Oop1
Oop1
 
C++ practical
C++ practicalC++ practical
C++ practical
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
 
201801 CSE240 Lecture 14
201801 CSE240 Lecture 14201801 CSE240 Lecture 14
201801 CSE240 Lecture 14
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
oop Lecture 4
oop Lecture 4oop Lecture 4
oop Lecture 4
 
C++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptxC++ lectures all chapters in one slide.pptx
C++ lectures all chapters in one slide.pptx
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Inheritance compiler support
Inheritance compiler supportInheritance compiler support
Inheritance compiler support
 
New presentation oop
New presentation oopNew presentation oop
New presentation oop
 
C++ prgms 3rd unit
C++ prgms 3rd unitC++ prgms 3rd unit
C++ prgms 3rd unit
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
class object.pptx
class object.pptxclass object.pptx
class object.pptx
 
c++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdfc++-language-1208539706757125-9.pdf
c++-language-1208539706757125-9.pdf
 
Basics of objective c
Basics of objective cBasics of objective c
Basics of objective c
 
12
1212
12
 

Recently uploaded

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 

Recently uploaded (20)

Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 

Oop

  • 1.
  • 2.
  • 3. Types of Inheritance: Single Inheritance. Multilevel Inheritance Multiple Inheritance. Hierarchical Inheritance. Hybrid Inheritance.
  • 4. Single Inheritance: Example: #include<iostream> using namespace std; class dox { int a; public: int b,c; dox(); ~dox(); };
  • 5. class box : public dox { public: int x,y; box(); void multi(); void add(); ~box(); }; dox :: dox() { cout<<"enter a number:"<<endl; cin>>a; } dox::~dox() {cout<<"number:"<<a<<endl; } box :: box() { cout<<"enter two number:"<<endl; cin>>b>>c; } void box :: multi() { x=b*c; } void box :: add() { y=b+c; } box :: ~box() {cout<<"multiply:"<<x<<endl; cout<<"addition:"<<y<<endl; } int main() { box j; j.multi(); j.add(); return 0; }
  • 6. Multilevel Inheritance: Example: #include<iostream> using namespace std; class a { protected: int d,i=20,j=2; public: void devided() { d=i/j; } };
  • 7. class b : public a { protected: int x=33,y=2,z; public: void reminder() { devided(); z=x%y; } }; class c : public b { public: void display() { cout<<"divided:"<<d<<endl; cout<<"reminder:"<<z<<endl; } }; int main() { c n; n.reminder(); n.display(); }
  • 8. Multiple Inheritance: Example: #include<iostream> using namespace std; class x { protected : int a; public: void get_age(){ cout<<"enter age:"<<endl; cin>>a; }};
  • 9. class y { protected : int id; public: void get_id() { cout<<"enter Id:"<<endl; cin>>id; }}; class z :public x,public y { public: void out() { cout<<"nid:"<<id<<"nage "<<a<<endl; }}; int main() { z i; i.get_age(); i.get_id(); i.out(); Return 0; }
  • 10. Hierarchical Inheritance: Example: #include<iostream> using namespace std; class A { public: int a; void getnumber() {cout<<"nEnter Number :"; cin>>a; }};
  • 11. class B : public A { public: void square() {getnumber(); cout<<"Square of the number :"<<(a*a); }}; class C :public A {public: void cube() {getnumber(); cout<<"nCube of the number :"<<(a*a*a); }}; int main() { B b1; b1.square(); C c1; c1.cube(); }
  • 12. Hybrid Inheritance: Example: #include<iostream> using namespace std; class A {protected: int s; public: void get_value() { cout<<"enter speaking score:"<<endl; cin>>s;}};
  • 13. class B:public A { protected : int r; public: void in(){ cout<<"enter reading score:"<<endl; cin>>r; }}; class C { protected: int w,l; public: Void put_value() {cout<<"enter writing score:"<<endl; cin>>w; cout<<"enter listening score:"<<endl; cin>>l;}}; class V:public C,public B { int avg,add; public: void out() { add=s+w+l+r; avg=(s+w+l+r)/3; cout<<"addition of the scores:"<<add<<endl; cout<<"average of the scores:"<<avg<<endl;}};