C++
+ supersed of Ci
To data Abstraction
4 object! extend =——_
: Ly encegsudadion °
4 Secare & pootalble fo atnhediance:
afd Payee phise)
o
7 ste
~ erdensible
> concep of Geinder
> (ask
~ eonpiyed lerguage, oops. stchrad,
The four pillar, $
e P of object-oriented Programming, Coops) In crt ase
funciona) +
) Eneapaddation : Thy tsahe coneépl of Inuslding the dade
cremate) and methedg ¢fnctiong) Ihak peapie oPerabe on tne
gala loro a single’ Unik cated a class.) Li alse favoives se striction
givecdte ACCESS 4a some of the objec S$ componends , oohich 1& d
doe. using. specifiers Ske private, proecred ,and oe
2) Abstraction} Abstuckoo Involves Wain compen enplemensedion
delatlg and showing. only the. essenhi
ans HedRs i reducing compte nity ‘and allows the, ea
Jig iaterface vathes an
OD feqhised of on obec,
fe es on interacting eth he. okjec
tg ioteenal wore *
ay Bn headtance,2 acnhensance VOWS ene HPCHERE o class
te Medd «grapestes “i “othetora cmetrods) for? »¢
anime, class: the cass \nhenda is casied the dlesved
closs,and the class bein inheried From AS cabled
dhe base class: ThiQ Psomealcs code. we suit sk yoogee*
Wi uel,
SEx
4) reject PhiS™) | pauimerphiem) Gilewsl ane! imerface te be
Us8ed for a Jemeral “class of actiona. The mosa corarnen
AYRES axe compile = Aime naTPHIEM .Cmethod oversonding, |
Jand mintime pa rrosphism Cnethod |
So pedes ce
c oversding ). Et encte. obje3S Of ditfenens- CSosse® fo be
e teed as object of a common base class. |
c
¢ PE Enca psullation,
°
class @ objecde
C
\ access specifier >" eyvate , Piblic, Pootected
A 7
co Benet of Encapeuladior :
oD Saba Hiding: Tmemal objecctk delle ave hidden fom the
c 7 outside world, the user inieact sith dhe. object: si
a PBN imerfaces
i.
> > ConteolS ever Geers & eNews , you ean impose.
TWES on howd dada tg modified Ceg:. Vastdedion)
2 The implementation dejatls of dhe class can be,
> redular
a7 aaidhoud- any ether parts of dhe Pocepram thot
Use SA, j
Acode mainiainabtsi 2 rd rakes dhe code move
omgpnized and easier to maintain,
tn= ie
ir inetude < Toston?
oer) namespace sid>
class Pessorn t
privede +
seg mame >
ind oye
public *
void seaName CONE n¢
name =>
4
=r qtname {
sehen name;
3
Void Sedage Crom of
ee bees) {
30
3 3 Agecrd
ins ey
enn de ‘
4 :
4;
robe.
ind main >
Pexson person >
person. sear Name CO sow) 3
pesson. sed Age 20):
cotke™ Name 2 <4 persed Fall credendal>
couse cennge BO pesson. ged agg? ge emal>
gern o;
3
en
fe inesnde ZioskecarN?
usted namespace atd>
ee Oe
eme Accom it
class
pave :
oulahe walance 7
previc®
Pome Accownee Cc doulate snvialBatemce) {
TE Ctnirrarsaioance do)
4
balance = gag alaatance F
3 erse {
palance. = O7
cake COM rited ralance must be PesiiveVord deposit Cakulste amount)
16 Cermouns: 9 0} ol
x a
babante += amos 5 :
card <<" Deposited sec amount << endby
3
esse
< ne
cork <6" Seposite amount must be Posihve |" dendky
j
3
Void withdrard Cdarble aya)
<
iE Camamr > oO && amon <= valance) {
Lealance — = armas»
coud <4" usidhdead ! "
3
y
date ged Balance (9 come { a :
rekesn balance >
J
3;tna
t
Pane A ceca
meine)
acca 1000) 7
aceart. deposit C200);
accamsd. withdraw C200);
pasance cree
weg accavat, oe
endle
Coud
Using namespace sid;
) class empheger
private * :
sranq name }
doulsle Saory >
tnek emplegeetd7
Public:
Employee caring Ms
<
qeknarne CY) )
sect salozt cs))
ack Empleyee ts ai
5
gare. &, tok $8),
ay)void sek Name Ching 9) «
ween = vip
3
Nord sek Salon} cawble s) {
i€ Cao) {
salon = sp
3
else
2
x
coud <<" Solos, must
5 ; mr
be positve }* 4 endh>’
s
void sek Employee ts cine id)
L 5
ye CXA dE) L
employers sid>
Esse
o ALY
£ ugk bE posave 1° 25 en
. xD ™
aouk 4 Empley®»
oa get Employee C9 comes { : .
aehkin employees >
a
1;
tnd mainc >
Empiedee emp (" Alice", S000, 101) 3
cout <¢"" Empigee rp: "44 emp gek Eopigees Cdecendl>
Cok CO" Empieyee Name gendt>
18 £geme. a Name (9 <
cok <0" EMP YE a. sec emp. qaeege <2 endhy
emp. seksodorey Css00e):
cou C6 “Updaded salanp:" £¢ emp get ening, O
pern OF
5
“4 Ie Cot
frineinde ¢ iosttea™)
aid;
using. nanceswoc=
Cyass Cov qt
private ;
clouble speed:
dosbic fued,Public +
Cot Cdoulle spd, doute )
<
serspecd ceed);
setfued OX) ;
D
gd sexspecd C double. 374)
a
weCord dro)
<
speed espa;
esse
t
cour ce" seeed camok Se nen VE YS enh
5
yoid seafuet ¢ doulebe- F)
A !
se (PA =O ei AKIO)
<
fued = FAY
else
‘ \y
are raed yess musk PE pedvoeen o* yoo 1 6k
3doubt,
° © .gekSpeed ¢) const £
Teruwn speed 5
j
— get eo const £
werwn Fuel;
3
void dvverd ¢
ié Chued do)
4
fuel-= speed ol)
i Cfued <0)
<
) fueh =O)
5
ed speed” <¢ speed <¢" with fues deves *
coud £6" OM
ce haad SO ASE én:
esse. <
v .
Couk 44" Nox enough fuck 5 "4 endh>
5
3
i
Take MOAN C r<
Cot (60 S0)}
dcendhy
Men es
Cat .
speed) eer vem)
Couk <4" speed *
fuck? S& nopn zeend
coud 6 NAued 2%
sie) name Space
© davble adfahwenhert edeosk {|
vero Gecelsius *S/s) + 32;
gs
daote skein) consd {
) Tew Celsius + 2731S 5
3
Le
ina main ¢ >
Temperahive. temp C25) >
Sauk <4" -pemperatwe io Celsius 2"
g CEN Tem pevahuse In Kelvin. '
vit.
43 heh tovipesats
circde ! public shape { pete.
a EE |
cijoss
pulodic*
Circle c deuble ¥) + nadivg cr) LYVoid deawc) ovewsde {
oud
= new Recrongie C41 63
shape™ S2 =
S15 dvawc)>
cout Ler Cawede Arex ® Y Ze St are zzendly
S25 das) .
coud: <4” Recharge fre 1 PLE SA ament) cc endls
debere S4>
aelede S22
wEeMen OF
ess specifetQ
es Alsraction Berd Acc pec’
eanesa cede! protected, public.)
72 Qimle4h include
class RanvAccounk {
pavade =
doulaie ‘alance »
piodic +
anv. Account G
<
Jpalance = leit’
doulate. initial Bodance)
Bajances>
void deposit Cdarete amen)
voV
‘ cE cama = asance)
oatance = amar h ;
reg = yndza® a8 2d amore Lena
cour 46 win
- sv nsnlficlen™ vatence pce?
vonVerda display Balance (> {
Cat Lo% curent Batance * » 4g toadance <6 endhy
3
i,
Rod wren)
x
Gane Accound account Copy}
Account, deposits C S00):
Accent , wsithdrad C209) >
accounts dis pe. oO:
Tem OF
= \s
v Reduceg coraplet
M earomce§ ae
amprvesg code ReUsalbt ve
Arvvstsachion cumpastans %
ay Absraciion using unter faces
a
cat does nok have O eencontl: tse ties Facea Whe
5 oa
Java, ede we can eimudede the 9s abs hac
classes anth onl pure Urrual Fanchwe .