Assianmers) 4* Page No.
Date..
How he pohess ODe decloed?
Ans The Suhae. of delassinq_place place C
a'x inb
inq ASsecded wtb
root ot he mame A pomeo is assecCHed
CApe Such 0S i and doube )too
Poimtea innalizahioo is a propamming
fechmique in ubhich poicmtey is assiqred an alchess
at a Niabe So that poiteo points a SpeciHic
Nalue.)
Exampe
inchuce cstdio h>
t includeConid h>
i t maind)
ind phæ ll Pointco decosaion
i t az
pta 0/pointesr initializohioo
05int f "In o t yallue of a . , X a
geth O;/
TEum 0
3
2Detine foinhez
Tbe Poimea is a Nmable that sth.
Ans
addressof another iable. A pointr also
c6es
used oretero anthes hex CaD te fu
t o poinl fa he nex
ecemenkd
A pointtY (an be inoementaloEyebenb
peaious memod loc
Hon
e
the pupos of poiter is de SOve memo
o n d Qchieye aste
ocaiom
Sp
me.
(RTS
Page No._2
Date..
plain poinmherr do obiec Concep
O t h exampk
Ans A VCmiable he halds on adohess
Chess Value.
is called paier yomiable CS simp
So similax to these pe ol d a t e a y p e . o b
Can olsO bae an adcbess SO thea is also
Danttxhot can poit to the ddess
s o an cbieT
otf an
his poiniex 1S aLanas (This_pointa ) CPoLOT
tohecd
Cxomple
indude isbeam h>
tinclude (onioh>
claiss mclass
im i
public
oid read (int
im agt i O
xetumi
Nold main )
mcass ob." object Painhea
obicct himeo=kob 37lqet shress
Of db
Page No.3
Date
obiecr Paimez 7ead (o )
Couteobjec Poinmer qet in O:/luse-2totol
get i t )
getch )s
Output 1lo
hat is poitey in OOP ?
this pointe aite_a osan
Ans Yeobiec In Ct} hos access to ris own
oclene ss dmough an inpratapt Doiter Calledthis
poioteythe his poite ts an implicit implieit
POometer to all membegAneions
iaiend funcions olo nal haxe a'this
PoiDte Decause ulends Coemot members
ot aCloss Only member funehions hove
a this poime ,8
Pxoananm for this poinhey'
E nchide iosheam.h>
USina namespace d
lass BA
public
(onsuctar clelioion
Pope lduuble 1E2.0, doube b 20. doube
Ouc"(onstucor Called"c end
engthe1
boeath b
Page No._4
Date.
heiqht=h_
dauble Volume()
getumn lenath breathd heia
i t Comad (Box box) 1olue 0
DEunn his> Volurne () > box 10u
cdouble Lenath ]]lenatth of a boz
dabe beath 1 Baeoth of a bpok
doude heia 11 heiaht ot a bo~-
int main rad)
Bex Baae1(33l2,15) IDec eebor
box BopeR6 6.0 9.0 ) IDeclane boe2
Coud 2'Booe 2 1S Smallea than ZLend
elbe
Cout e"Beze is equal f0_a nga than Ree1e
etun0
Wante ues fon qpkacha Ovloadig
Ars Rules fo openodox CYe loadina
aadinain Op
On builtin Opearons s Can
Con be_(
be
New Upeacnoas CCn De coeaBecl. Oeb
Page No.
Date.
b en a tb e -
h t t h e opeaatoas Can
chamged the
O ft h e
y_of
Pre Cendance adassoiohiytsy
Opexcrtoas Canmat be Chomoed. h a v e detau
Dec
Cnelaaded opescctos Corhat
0pe C a l l
Cquments
erY exept the function a d
ume
Cipeaccto Otubich can have cheiu
Cpe
builod
9Cpencnaxs Camdt be oneboaded f o aDo
ih pes ODy AA east one. ap-e
must be used definedpe tunion
Assicment (=), sub/sirt
call" )member Sekechhon. -).opes
mustbe defined CS membey tundHons
in poi
Exeept he opeaatos specHied
be éithe
b,all atne opeacHons CO membez
memDeY fundHons co pon
tunciloynS
8Sppme apezcrtes ike lasshmment) loddoess)
and lommon ac b defauH ENealacncdec.
6 hoduce polymmphism th ts type
Ans Polymoxphism Isa Aeahund_of oop thrt allo.
he Objeet Ao behave dliffesentN in diffexet
COndiHons
o (t uehave 0pes dt palym03phik
IS(ompile hme pohmophism
This s knoun as Starhic (Oe caly)h
2Ruime polymogphsm
bindinaA
This Is aso knaon_S chomic(c bBe) hi
binding
ATCO
PageNo.
Date.
Omune funeloo oV [Link] opta
lcodmge
Ans Funchion ovesoading
Canhavemutiole definHons
Same tuncHors roome in he ust
XOpelhe detinatop of funeHon m
d ffcrend rom ecach othey ty he p
listou
and tr the numbey of aoume hat d i
Coanno OVeload funchian decootio p
only
Ou CaYm have wo tun1ons
Dint Qacintx,cha
1)intatitx, indy){S
At kast one of he qumens must
dtfex in he data ype 0 the aaclea In
wnich the paxarneicas Co passed should
not be ot Same Clarte p e
Cpescho cNeylandinq
NOu Cam aedeine cY OVerloa.d mos
of
Hhe bulB operatoys chyailable Ih cttthus
a pabpaome Co CpexatoSuth.
USe
tusedefined lni.
pes Cs uel theae you
CaD use Opexcrtox 0s a tunchon do l o
tusk other than
What r geally dees
Stax
'et-Ape clSS-nameOpecthoy }(Oroclid
operOAons
d a d p e is the 3tum tPe
Page N o . 7
Date.
th=
whch
cass name is the name of class io
the
Opex0Bo) 15 lotcked oith
s the plotenolede i.e eplato #
Opexto Jo be Oveloqdecd- o p e r a h o y ¥ t t
Ce opeyaHoy topeorcr do be passa
g-liis the lh of gumes
fereione between_comole ime and
ounH
Dif
pmoophi)
Ans Rantine poly mophs
Compile ime polpmo phim
Dlompile me pokmoaphismRintime pokmwaphism tUheae
aun iome we came to
oeavs binoinq is octLgdt
Lomplle ime knod twhith methodl 1S doing4
oinvoke
DH Can be Ochievec) thotughECn be Ochtvedthoough
Stahic bindina cmamic bincling
Tabtecdarnte is iot imolved3) Joheatance is tmoved.
)Melhod ovelomding isan Methocd evendinc Is an xon
example of lompke 4ivoe py lpe of unhoe polmor
mophism phism
Explaico snhul poe NIhal funchion.
Ans Vhuafundon
A NIHuahuncion 1s O
memberrinds.
et boseclossuuhich Can be edehine by destred
ton
class classes havinq stual Juncttons trel
dt not
TrO
Page No. 8
Date.
SapmBax
vitual <undpe itun -Damez(
lkode
DefindHon S qven 1S base [Link] cless
haNihna unction Can be instamHiated e ts
objeelcan be n
made. If cariced class do
edhine Ntual funcdion af base clasShen
E doesn E ki CompiladaonAl olevedl Clas
Oma no+edetine Mtual functfon of
base tlass
Pae Nuuaunction
A punt Nmulfuncaon is a membe tundiea
ok base_cass hose Cnly delagzc iom S rovded y
base tlass hen mo cpapticedtipn Should be
defined io derived class othemwse clexned class
aso beComes gbstyacBase Class Couinin.g
lpune Ntua funchionbecomes absrad
SuntaX
NitualZunApez<tun-nCYme > C)
20
No definhon is given in base class. Base
dass hove puae ntual üntion becomes abst
ga ie Cannot he msBantidBesF oherived
Chess do o t oedtine ovhtua functlon at base
assnen mo (omplicatiomAm0buf ceaiyed
class also be(omes ashraet ust like base cla ss
fill derned lass ymus zede puae lIhua
anchion o base Class (ATCOF
PageN
Date.
Oveloachinnq
pacgaanm tor tuncion
and apeacttozaNeDlogclin
HngouncHon [Link]
include ioshsamh
Usinq mcmespace Std
Noid i t inti)
tout ci Hexe is int<1(£end1
Nolc pi (double)
Cnut c"Here is flaat fLLend
Noid mit (cha Co ns) X)
tout e Here is cha CLend
int main ()
p i t l1o)
point (lo-1o)
i"Hen"
Ohprt Hene is id b.
Heeis fload [Link]
Heae is they deD
sOperodo Uyex bodinq
Eindlude Linshream.h>
USing Damespace kld
chss Complex
poiNahe
iD TealL mmge ATCOR
Page No..
Date
public
Complex Cint 20it jco) seal D
imaqi :Y
This is auBomaticallk calec ohen4 is used wlth
behueen 2 omplex objechs, (omples OpesctoxT
CComples onstob 1
Complex yes
[Link] oeqt obi rERal
ES imag maaob mags
Tetuon s
01d paint ) {outccrealH'Aimaq arend 1
(ormplex t (l0,5) , o(2,4)
COmplex( C1 l2; An EXampkcall Ho 'ojpeachao
Output 12 tig
(aTeos