Oops Assignment PDF
Oops Assignment PDF
Pord-A
Saatht
e tho ul ot Mu opinat.
GOLatoh_danHO3 O nequalA
The n o s
Syntaei namespaee
L/Code
LICode
Page No.
Date Saath
ThaPinline Ruwhdul
tha onlua
hunt to compulih and ut upto th
decdo
compilh to
whuthaa tu ununs_a
funckhom o not.unline fundtiom Can
A SI2e ot Cmpulod proqgm ince
this->value = va lue
tnt man C)
lCade
geturmO,
Page No
Date
u9. ohan ue
we stattc data
Saatht
Amg In
Cttstatic datu membumambers 2
a data mamben oaclasa On Wod t
to bshaatd ammg alU or stut ndb m
/ltode
Pag No.
Date
Caath
class De1vedpublicBase
public
UDLd print O
lcode
intmain)
Deatued dj
Base bd
b2pr10t)j
thunn 0j
fage No
Saath
a)Raakility
Claas templaki poudes a
Uy to Chaata at ulakle. Cods. Once a clau
tmplad ui dahunad tcan 6 tud th
dhurand data typo3 to Chaat instanc
h i clai Thu sauts ttmi and ehbot aJ
t eliminats thA ned tu Chaata sepnate
dosaes ft each data-type
)flexiblity
Claa templata oulut t r Alaxikd
In paqammig.Sinco a cla ttmplati can
beud in duferent us data typed
allaus dudopeni to oaats paoqram that
Can w k uth a
vanlty e data typas
Th paxtialonly wsthul dn s Huotion
h u the data typix a not Enamom ad ha
tm of coduns
C)yPSo-aty
clus templak1 prautdas tyee Sahcty
whuch MaoNJ ithat tho COmmpilocheck daka
type wd ith ha omplatr clas u
enn thai t matcho: the expedod typ
Tha holp to catth eros al
tim puhuch ui mone
erCompil
ehbiciont than catt hur
tbemat nuntme
Page No3Y
Date
4)StandandJuby
AAth
Most o Jhsstandaad
cloaA dn. Ctfo dmplamardhd oda
lura
d ukan
Lcmplals8,Such as condau
alsand mapaThu mak
Jika dto
towethode clasäeg tth
eay iur dautlega
typs oubnantdata
Thael ny o unstantat
tunctom
a
ttmplak
Imalicit 9natcnkatun
Implut undtardat-
Ld
erCUnb when ih
Compiln enurdunz
a call ta o tunction ttmplata. At Hhu
paint
thicompilun geninatel a n intanca o th
functim tcmplau uding tho datn tyAs
hoxqumintd pamadad. Iad unstantatn
happeni autmaticaly at Compul tma. Ond
th oesLuling tuntn s ad fa tuncton call.
Ex tcmplate< typenameI
Iadd(Ta,Tb)
getuan atb)
fageNe3S.
Saathi
2)txplicu e9natantatiom
expuctyinstantiatt a tunctim tmplat
tor a partiaulan data-typeThu don L
th template keywohd follmutd by h
tunckiom sanotuns and he idatatyee in
anql 6xoc kots.
E
tmplatefloat add<t loat>(tioat a yfloat
3) ExplicttSpecuaunaton
t u d when
wand to prourels a specule umplamuntation
oh a templas tunchen t r a pastheculan
e tun + 4b
36
Date Saathi)
What u a
templak Explain wth thu halp
2Explain
ha tuncton
a t Cao be
udd knth dublgruns daka
ypes Ths elumunatu
thanud to wd
enats tunckim& or clauu fr eath
typa and impxaUt Codaatulabi y.
Templatus ana ued ta Chaats
uc claslatunctiam and daku shucturo
thal caa. be s k uth cdhbnunt doto
yp
Thins ona tun t y r ttmplalu inc4
aFuncttonTemplate:
b)class Templat
lcode
3
Date
Saathi
Ex
Hincludeioshcom)
uSinq mamespace stdj
ttmplate<typename T7
Todd CInumlInuml
LnE maind
etum O).
emplat <class I
class classname
p Vate
Page No. 3
Date
I varj
Dublic
TfunctianiNa meLTury)
Example
tt ncludekiostatam
LSLA naMespace Std
template <closs T
class Myclass
piuatt
Inuml,num2 j
public
MyclagsO
Myclass(T numlI num)
thisnuml: numl
this-mum2: numl
I addU
Tetun numltnum2
35
SaathD
..ntmain1
2 +35
2.243.3: 5.5
eye N QQ
e)Ived Cous
Drte
Multloeel inhuutunca
HBase class of y
Subc lassl dey veg class ct
Base eless of 2
Z deatusd clas.at Y
tttncude KLostream
USLng mamespace Std
class Basel
publc
vaLd Shou)
class Base2
public:
VOId Shou)
public
llCode
n t manl-
Paye No.2
Date athi
Dea1ue d d
d.show0, biguutya
2tun 0
Rexalpe Ambiguuty
Thu Ambyuutyca
sourd i n y thuS
SCope aesaluton tunction
tntmain
Dexiued di
d Basel:i
shaw);
c .Base 2Show ( ;
aetu mj-
Outpuk
Base class-cali4d
Rase cla sS -2 called
Page No 2
Saathiy
Object-omentcd parpaamminy(oOP)
oop da prognammMng
paxndym that atsduelanaund thacCanta
a obiectiuhuch_ane dnstonced c l a
that encapsulad data and behaulcu
In oaP0 clalua lupInt
ttmalat that dskinti thaphopentuu
and mthorela d an_objeck.Propnai ane
ha dlata mimbao vanalblai that str
thidata an obyect and mithcels ana
th tunckin puaduns thad opera
n that data
Obiect con pBenct wath each_
athea bu Sencdung mageswtich ana requo
t r a particular behavLan oh achn
Thu untthactonu baled m thpr1NLpla
en.capaulation,unhinita nu andpolyma
philm.
inherutance uhuch maku ths 00p
Cacla moi moeluulan Raln touldn
tuld a relak1onshp betuten claiue
Cncapauilakon can hds Sora oha piual
datas ok a.das from.othan olyecti uhuls:
Lpulymomphiam Con oullw dlnula a Cornmon
opAnaton un duskrund unya
00P udaly uuad un softwat erginai
lecaus J praudu a pcwtrhul and flextba
y mcdel compliz systmy
Page No.uy
ath
Date
2 PaocadurolprngaamiOop falLnua
to-Uatusa top- daTum bottom -up apprCaCh
appraach
anc inhmutance id
Jnhant
Cancapt ok clata huduryhdiny and unha
13&xample:
13 CfoRTRAN,|Examplk*ctt Java
Pascal Basts etc. Pythen
PageNo. U6
Saathi
Dote
fage N