Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

le inihàlizaton ii ¬x-tens iely used in shet

ARIA.
mic

n t e d T g tammin'y
en

weut 3 KEFERENCE VARIA2LES

vaswable knevo
knero
aiu

thén CtInitoduresa
nes krod
f ot
vauaslh

be
pLDVVOA
vasu't
Vauabe . A
leaenc e Vau'ab.

Me Jenunu previowaly
dfjid
name fer a
a
tesn ati fo/lerae
cuealrd
as
u
vauie&le y a r la 4 e- n a n m e l

Aefeyene

c e n a m e =

hefein
k
datayye

loat otal
=
e
total
totalL
i b r e a n t

Sum 5
R
oat d h c d a r e E
6
h
h
o
e

m a m e
se
k eff
e ru
e a

a l t e n a t
ue
i
V
Vau'ases
a i a s e s

tun B t h
B o t hhhi
i

Sum
s
t s / n l .
Colal mumo7.
m m e y .

atia
ble 1n
7le
The
6yec

tata
S a m e

C o u t 2 l s 7 a l

an d um
value l
/oeD.
.
value

tuhe
prmt
Lotu

The Stetemen
s

ttal = tolal +18 and


and
llrum
um
to
é ot
trzdl

tue Va luu 7 Lot


will chatfe
Chate
2 MmenT
The aes

Sum=0 Ll 6 zag
zak ass
7he vastaLl
The vasla
Lot
tua yalu
wll chanse
be
inHtalized at YRe
must
Vesiole
depesenu
time sdeclasaion
b he KymbstT
adduttbnal meaning
Ctt as'g ns
addlsr herat.
H e u , 4 u nat
an

Int ntioJ
Intx =
nTio //« e alas pr TioJ
ba
cha aa
*\n " nitalíze eferena
Literal

ako allrued:
The sllon efrort au

nt

nt m- *%
t kn = 5P
& huos
Cause
m iefeu
declasaticns l)
The fxt t t f and he
laliman
-

the poinlto p and


m a m

ponts by witt
valu S

L e al
tii dn t 6hétt-
CL
(
vatva !lh u in
eyor ayplr alion bfheJeunce
asgument Junctorl.

yor Cnt x ) usa Jante


alro
itnuumenti 4, s o
c

Ine maul)

nt m = /0
funeticn Call
ftm)

3 pllaw-
Call flm) u eK-eeuttd, 7he
Lhen Th1 finetrn
initolizatron occuus.

Thu
Thu become an alrae m afe eveul
Slate me n t

ftm)
Iueh functr on Calle aue knnwn as call y eue
Sueh
Int m=l0
lo ne tocaZidn
Call
l o boo nams
ftm)
LRx=m;
OPERATORS IN Ctt

Copuatn
o p e a ,A
C Kas a At'eh get f nu pudn
C r n t w d uiey
some

vald i Ctt,
Supe 6eeotutrom p u a t r

d e c a r a t o r

membed
LS
pointe
da/ir
6
meob d sp
poime

S m e b e peAa/T
po1nu

Anleas peato
olelel Meme
endl
une fied zpsalo
Memey allocalin Epdal

Field w s h b u a t
Ceto

DPERATOR
DLUT7ON
SCOPE RE
lasgueje.
6lock stauolankd
uRe t , Ct+ zi aleo a

Can be uaed in Cnituctiy prame


Blokt and Supes
Name Cao s c
uaed o hkbe a runt
The Sam vaui'asl
stoki.
meenii im dilonunt Gom lhe
poinr
exunds
Vriiasl
the
The suope 5 e
erel
tlok
d t h e Llob
7 the
*Ke
decdaratión
tll

the dec lasatren.


Cntain 1 Ltock
Ltock ui sai'y
çad
I'nsiole aa
decdarsd

A vajalle
A
e Ceptar speiaToe
b e locul t lhat blo ch.

Int = /o

lockL

Block 2

dectauatien
blockL,Thata
l o ck 2 ConTainedih 7hL Kame
5The
Same
deelaatrom
hroles a
n e t lotk
C n
in an
a n

and
huepe,each

Bran Valesle
a
ann
sue block

kefr b a deent
es ion declasahen s7 z
caudu te

the ineg
block h e
Vevase

ct & data é u r
Aithin deelaod huu in,
deelaud thuin.
bte
edata rje
will kafu né- be
can

n vasi ase
veuion C a
LB
S LT
hus
huqtvbal C
Lloek.
blok.
InCC 7h* rttun he
Re twrthin
onet
ne
Callud
Gom
ecerseod
pua/o:!
a Des
Inio due a
used
can
Le
7hi
edshetén puatar
Th Sope he olnsi
h e ollosvip
takus
hidolen Vauasl. I
uno
. . yata Sle
-name

7A alles access
he glElal vusen A
palor
Valale

*iclunde K1ostiam>
ld
using 9o mes pace
s lsLad m
int m=/0

Int malul

m dAecdeetnred, bcal ts ma3


tnt m 20

int k m
Intm 20' l/ m /eclaicdagaie
L o c a l 6 mn s4lock

Cout Le "we a u w nnet block ]»*

2
Cout 4he au n tudu block \n
Concl< m
Cowt << * m = "'ZLL m z e "|u"

ATuw D b/oR
m = 30
DEREF ÉER ENCnIG OPERDTORS
NIEMBER

petmi 6 o 1 f n e a clast cn l 1isng


C
yout'os ype 7 data and -unioy & a s merobet
membe14
clais
also pdmds u b a c c e s thi
Ctt

Thuouh pontti
mem bet &7
&
nmem
be
t
to a
oa
a pointu
7o cleclau
a clas.

m e b
UsIn 3ep
access a tIRatmemby
To
peinlaa
a
ame
and
n poinlez
a
uIAJ
membey
a o nt i o h
t ha
a
aCcK
70 onto
peet anola
h e

membee.

MANA4EMENT
OPERAToRS

(3) MEMORY s allocals


mallocl) and tallocl)
tunctrons
uses iuns
C
C imilady,
at un tirie.
mernery
dynamltally
allocatitd

ths
Th n con esk) to free Aynanm/qly
NÁun
alto cathon ilyehni'g u e s
At se dynamii
memry.
Cuoro much memoy pate
advance
t nU knon
ntedra

iz also defru tor


thuas functrone,
C+ uPpt h a
tha t pufm
delvte
neo and
opeuntod
Lunay
e
the ask o/ allocahi ant feeiny the e m ey
ne POIn
bete and easwe_way./
ai t h
Sin thut Dp elatod manipulitu memry
Slre / hay au knnon as hee dtrre plhatr
7
An sbeit Can Le Clealid y uainp nap and dleslirte

by uonp delte, as and isHen enurd, date bhu


by
stock LwIt neuo will Kemain in
cuatid tn'ci'ole a ,

ex) skna until t e expli cikty datyo7 wwin


delete.
Can e used bs ceala bbjec
The ne puaTr

any type ne Aalaly pe


ponles-Vasiagle

whe P
1 u
P
2

aa
ne nt
nea float

bo/ntz 7 pe iit and q u


a

float. 'we
Combiri the oleclatatiéón
Pona type
'thuu assgnment
as follaos
pointue and,
hed 1nt
n t * P=

float *2 =" * n a o float

*P=2S
ls the new«ly Cae ato
= 7SS as'gn 2 s

Int sbec
and 7 l s he loat oyeiY
mery
Can alco 1nitralize t u mem

the peAatar.

pornlu VaitaLle =
neo datn-pe (valus)

n P =
he intlbc)
/lo at = = nao float (7

uued & cnwat a memey space o r ayY


e
neu can
auays, U
ih eludin Lau -depniely sdeh as

dataype typel
Sudetaus and lasses.
u
6Ne olimencional a a y
enetal />m a
The
be = »eus dalatype Lsizu
poinb-Vaita

mumbeu / elmenke n Ri anay.


the
Heu, sice specifies
n e ,1?nE[iO7"
nt p=

an auay
aMay b7 nbgeus.
lo intsgus.
s7 lo
Mealo -a
memoSpe ce r deconef
PLI& t k
Aefa &hi a* elemenA
ploJ wil
and Loen.
ele ment
rtR Na
mulhdimensiom al atays
Shun a L a t n
all t h andy si2s m u s Le Kiypple ,
aMay-pli- neo ntT37t ITu7: leg af.
aypk= ne0 1nttm7LEIt47;
amaypl =mes nt C9Tts II illepal
saypls = neo ntt I5ITv; tllepal

l a k t sampl

privalbe

datalype d1
olatr-tpe d2

publhè

manl

Sample *pk=he sample',

Lshon a dala hyeit u no0 lomfu nèede d, t is


odstisryce
t e l e ase the nem pace r Aeua

delete foitvajaslG
de let P
deleto ?
alto tatzdouay
tay
altoatzd
we Oant-sAee a elynamitaly
T
n7Vala
must
uithe folloss
llde PoinlvLJale

B7elemgn in h e aMY
tlu numbu
7 h S/ae Specifjes entre
lulet an
delets
CIP / wl
nE aaitasa
memoy u
In
Jn case
case hrhen kufhveot ull
null
e
ettt
iaunnt a
me
M es
o
ralloclf
allocAtreinken

Forr
pomle. es

9 advantag
tas_foltnom
ofur
The neo peal malloc
Otkeunttm malloc ()
(9.
the data
compulis heS/zè7
adomatrtaly cizeof.
6izeL.
use thu p
he peeta
atto
r
we
need ft ppinles
Bhycit. FKe
c o r e t F

mekmns

automati
cally e a
lypetadt.

P need
b
Thns ufe
s6jeet S%,Ce
Sk:Ce

c
he s
the
t 6jeet
type irtalrai
I n i b a l a i

poreile
(3)Pt
e a l i n
is t h a
p a ce
m e m o y p a c e

can

llete

and
s p u a l a n r , n e o

ohus
uKe
K e any
C
se oveyloaoled.
4) NANIPULI oR
tanu u e d A6 er
Nanipulelors at sbualorrlha
most commenly ned manlpa
waeamanipa
7h dATR duphy. 7he
- tors a erbll and cetio,

7he tno/mani'pu/ater when used in an c a p u s t t -

- ent CauaLs a lieleed be ncutrol. hat kame


eHect au weiit te heclune chaacla */n"

Cout 2< m = " e m <2 cndt

24 "n = "
<e na< endl

4p"44 P << endl,

weuld cauaec thive linu


culpu,
m =

n 4

SL Lhould a tlu
appcai al unclu
m= 2 S 77
n-14
P lS

Heu, t nurnbes at
uikt uutited.
The Cetuw manipulatr

setoCS) 22 sum endl


nanip 7he
Cout
manipulatiy Setols) sppecefes
a
freld wlHs
7Ki
s

cum.
aitasl
the value o7-7A
p nf fes,
w i h in t
yelu ght judttfhed

3 Ss
0tam2
Includ <iaiiuam
# 1ncdude <io manip>
nameipALU
LU
u l in

n t malul)

Alowance =9S
int Baklc =
90
Ttal l o 4 t

Setolo) z
aBase" ze L e t w t i o )
Colce
B a s i c ezerd
s i t llo)<e
uAl/oroanee ' 2
setotto)ee
Alndante < < e d
76/al
setholio)<
u7tal"2
Sewlto)e

eelun Basr
A an jo yS
7YPe CAST OPERATO
(3)
Ct pemitt eyplhtub type Cnveson 7Vati'a Lles

exprerItent LaAIn he type Cab peuator.


The fA lnsin twe veusrerv a efuivalnt

(ype-name) expression cnotatrin


ype-name eypresson) e t+ nstarèn

a verae =
Sum/ CA10at) 2 /¢ tatrin
a velgpe Su)loatti) /A+ nstathen
Progam
tnetuol jesheam
ihclu ol Corio h>
s i n na oespace ctd

n t man)

Int ntyai =
S;
floatfbattav = 3 97

"
Cout< " intVai =

*nftoatval=
"
Cfloatva,
Cout
"<{loat(intv
\n float Cintvas
=

Ccout 4

Cottee"/n m-tftoatvat)=
"
e nt(loctvai);
gchl)
ole / nv a =2S
loatVat = 3B7 Ine ( l a tva)= 3
float lmtvat) -9
DpERDTOR PRECEDENCE
enablu b add meaninj t u
c t4 uu mutipl
a
and predeoten
ealos yet h e i assoceiaticn
suumon t t ame

AsO Ejatiity
pelaTor
lelr b Taht
leP o g t
.)C] poai* + pasfu-
- unuyt
pr tt prf*- unay
unauy
*
Lunaly
ctyde) Sieeanes d l i

lef
t

left t Aghs

==!=

et Aght

left &
left ts h

t == lzht left
*
=/=9:
< =
>> = l = A=/=
, (comma)

aLtume hijhe
h j h prec eadnc
precednd
7he unay
epeatront

You might also like