SlideShare a Scribd company logo
Oop
Oop
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

DOCX
Simple example program for inheritance in c++
DOCX
Doubly linklist
DOCX
Cmptr ass
TXT
Card pack
DOCX
WAP to initialize different objects with different values in java
PPT
Cryptography for Smalltalkers - ESUG 2004
PDF
TypeScript Introduction
Simple example program for inheritance in c++
Doubly linklist
Cmptr ass
Card pack
WAP to initialize different objects with different values in java
Cryptography for Smalltalkers - ESUG 2004
TypeScript Introduction

What's hot (20)

RTF
Class & sub class
PDF
LLVM Workshop Osaka Umeda, Japan
PPTX
Oprerator overloading
PDF
Kotlin, a nova linguagem oficial do Android
PPTX
Cryptography
PPTX
C sharp 8.0 new features
PDF
RediSearch
PDF
Searching Billions of Documents with Redis
PDF
Live in shell
PPTX
.NET/C#_6
PPT
Lecture20
PPTX
Go之道
DOC
vbscript-reference book
PPTX
ClusterDesktop Socks5 Proxy
PDF
メディアアートにおけるプログラミング言語Rubyの役割
PPTX
Elf文件解析
Class & sub class
LLVM Workshop Osaka Umeda, Japan
Oprerator overloading
Kotlin, a nova linguagem oficial do Android
Cryptography
C sharp 8.0 new features
RediSearch
Searching Billions of Documents with Redis
Live in shell
.NET/C#_6
Lecture20
Go之道
vbscript-reference book
ClusterDesktop Socks5 Proxy
メディアアートにおけるプログラミング言語Rubyの役割
Elf文件解析
Ad

Viewers also liked (20)

ODP
Andrealozada
PPT
Admission in india 2015
PPT
Inheritance
PPTX
Hierarchical inheritance
PPTX
inheritance in C++
PPS
Inheritance
PPTX
PPTX
inheritance
PDF
C++ Multiple Inheritance
PPT
Linear Systems Gauss Seidel
PPTX
Gauss seidel
PPTX
Solución de sistemas de ecuaciones lineales.
PPTX
Matemáticas II ecuaciones lineales
PDF
Jacobi and gauss-seidel
PPTX
Load flow study
 
PPTX
OOPS IN C++
PDF
C++ OOPS Concept
PPT
Gauss sediel
PPSX
PPT
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Andrealozada
Admission in india 2015
Inheritance
Hierarchical inheritance
inheritance in C++
Inheritance
inheritance
C++ Multiple Inheritance
Linear Systems Gauss Seidel
Gauss seidel
Solución de sistemas de ecuaciones lineales.
Matemáticas II ecuaciones lineales
Jacobi and gauss-seidel
Load flow study
 
OOPS IN C++
C++ OOPS Concept
Gauss sediel
Inheritance in c++ ppt (Powerpoint) | inheritance in c++ ppt presentation | i...
Ad

Similar to Oop (20)

PPTX
Inheritance.pptx
PDF
OOP Assign No.03(AP).pdf
PPTX
Inheritance
PPTX
inheritance in C++ programming Language.pptx
PPTX
Inheritance
PPTX
INHERITANCES.pptx
DOCX
oop database doc for studevsgdy fdsyn hdf
PPTX
inheritance in OOPM
PPTX
Inheritance in c++
PPTX
Mca 2nd sem u-3 inheritance
PPT
Lec5.ppt
PPTX
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
PPTX
Oopc (group 9)
PPTX
labwork practice on inhetitance-1.pptx
PPTX
Inheritance
PPTX
Object Oriented Design and Programming Unit-03
PPTX
Inheritance
PPTX
PPT
Inheritance and its types explained.ppt
PDF
c++Inheritance.pdf
Inheritance.pptx
OOP Assign No.03(AP).pdf
Inheritance
inheritance in C++ programming Language.pptx
Inheritance
INHERITANCES.pptx
oop database doc for studevsgdy fdsyn hdf
inheritance in OOPM
Inheritance in c++
Mca 2nd sem u-3 inheritance
Lec5.ppt
inheriTANCE IN OBJECT ORIENTED PROGRAM.pptx
Oopc (group 9)
labwork practice on inhetitance-1.pptx
Inheritance
Object Oriented Design and Programming Unit-03
Inheritance
Inheritance and its types explained.ppt
c++Inheritance.pdf

Recently uploaded (20)

PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
OOP with Java - Java Introduction (Basics)
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Well-logging-methods_new................
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
OOP with Java - Java Introduction (Basics)
Embodied AI: Ushering in the Next Era of Intelligent Systems
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Arduino robotics embedded978-1-4302-3184-4.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
CH1 Production IntroductoryConcepts.pptx
Well-logging-methods_new................
CYBER-CRIMES AND SECURITY A guide to understanding
Operating System & Kernel Study Guide-1 - converted.pdf
bas. eng. economics group 4 presentation 1.pptx
Structs to JSON How Go Powers REST APIs.pdf
Lesson 3_Tessellation.pptx finite Mathematics
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Model Code of Practice - Construction Work - 21102022 .pdf

Oop

  • 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;}};