Classes and Objects Part2
Classes and Objects Part2
Classes and Objects Part2
tdata C)
ARGU MENTS
AS FUNcT ON
DBTEC7S used a4
be
an bjeLr a y
h e t dnTatgP in to0 uaya
Lkea2y can Le elne
nt /7his
aLjume
hun cliik b thopivcho
sbyeet e bate d
7hi entiit
a)) A
a C a7
A cy u
Ziansfesit of
Bbjecti
thu addie 57 the
6) onl
aunctTén Sinte a c7p
byn l u t .
mituod u
Calledpass
ckagzkt
chang4 |
A) The fiT} the Purniin, ahy
u passe cd dot- apet-
Th ec the finetton do
tthe b t r insiot
mad
leed & t a l l
the fun ei in
h e brelt+ efnence
bas by
m thod zt called alle
ecomod the
7he ii babeed,
adertk1 07 7he byet usedin
hen an
ettial b/ett
cren
wwkt dueetty sm he maole t h o
Aen ns" t h a t any
chan4es
me a
7h kL
h e Call ftincthin dia
yotinsicl
The
Dhje ct, 7he pak by KefeAen cemetim is hmrre
addrend
hwnt Sine t Kleq uneA p a tnly the
5
of h e 7hyett a nod n t he entu t e i
<iostre am
cluode
t amespace S t a
ASin
clast vme
h houk
I n md utis
publie
o7d getime ( hi int m)
Sheuus =h, miouls = r
3
Vtd Futtme Cvtel)
.
" Kounc ana
Cot zhoult
ez "minu te e"|n"
miutu
C o u s t e
hous = minltI /
mihutu = minulis % 6o
hot
houts t H.hovis + ta
hoats
2
Int main ()
TA gett1me
( 3,30)
/ T 3 = 77+72
73 Sum(7L Ta)
()
7Z p u t t m e
"TI =
"
Cout L TAputt1mi ()
L "7a = "_
p e t t i m e()
Cout
T3
e n tA
3 al
an
aAgiun)
pated
can
alto se kuh f n chons
ec tMaeve,
An
n m - m e m b e l
functon.
member frun ct ens
a &the publé u m e n
k
ccek al aig
Can
hae
a
K6/ectz
pasted
al
leee
irrs
h h
the Ra
a ee
enly tlu
ough c
C aa
n nn
n Stf
t
ctére
pu'rat
here data membetg
t .
fRIENDy fUNCT70NS
e e d n t br a mernse Y7
Sueh wttron
lase
out)ote. Finehen Arenody
o make an
class ABC
Pubhé
precedred
by H
leelacatión
shold Le clsesheu
In
7he u n c r n z cefnes
fineton !!,7A
filend.The sptualr
'keyworcl éegpe
hene ar
he Grerad
Ke ky+oerd
Th psegram
declasd
uitu
can
se
au e7tn
utions
That
functroid.
A fun clastes, , 1 oend
elaRA ren
knon as heicd auyNumby
7
auu
1n Ras aa
cleclaieo as a nend efron, kat
memasgun
nsta
altnoug k 7 he
tundon hepuvali
membus
Class.
Chatata
Ceta
Epeial
posk esse
he elass s h ch
1 -he Seppe b7
naz
O SR Gien ol.
been declasua as
Ca onot- be
no iD Thi 6tojpe
B7 the clas,
Since i-
the shee 7 ttar
clas.
Caleel uin Furctran
tithaut
nomal
like a
Inope
an se
)
help57 apy e c
c e e
Thu
a
thu Can
ndt
fiun ctioms, z w w e an
4/e
a e ir
Dnuke
membel
hos b
has
u ea n
9 ande ate toth e
eaacA
A
haes
dseely coth
memsei eJperator
meduship
dot
and
name
2 n e m b e t n a M e -
The p u l i c
or t u
ertis
tu
e l e c l a i u d
can
be l a i s cwtiuout a
a,ffeltp
cwthout
Z
ts elas
p r v a t t p a s t
7a
mean i n
agumen ti.
a s g u mentr.
a
tas thu ohyeits
(6) LAualy.t
PRoaRa1
#mcud rostveam
)ameRpau
tte/
A ing
.
c l a s Sample
Int a
tnt 6
Publhè
Vetd set va lut l( E a -9; b=uo; ?
krenot toat meao Sample s )
oat meanCSample s)
int mam)
sample X
X Setvaluel) X )2
<<<
" e< < mearl X)
M e a ) yalue
=
"
Cout
cen"
etcun O,
clast X
In fund ()
class yy
u fheod1Y
3
The fuochn funll) a membet Clase X and a
nend s claa y
claet he menes
8)Al Khe membel hinchins bf e at
clais Z
PRDaRN
#*neluoleKioklLam
nnameepace ld
class XYz
n? dala
publhè
Vor' setvalue Cin? va/uu)
datr valu
3
PBc)
vor'eldel(XYz,
t9end
3
class B C
Ine dala
pubhè
int valu!
Ver'd setvalue
d a t a = Value
r e n dfeneh
hunehi
erd
add lXYe, A2 c); d c l a t a t r o n
rd
end
,
Aec )
add l xiz value XYz
X ang
Yz a n4
Verd valuet 7
odata
S Cout
"
Sum hend
ectt ten
c dala
oh2
t j s .
dats t
hunchon
*saf'o,
Int nman
Xyz X
Aec A
. Setva/u L)
ASetvalue lso)
aolc!X, A)
ALtun 0