You are on page 1of 25

StoPoge classes

Stoeoge clasSes1S Language ince


ncepe
Concep Csimi1a in
CCt+, Java,
The Con Cet of Stofa qe claSS S boSe
on
on he
Memog which e allocated Foe
he Uafioble.

the TechniCa0 Co e &


Code
De have
ec
o undeestan'd the
Concept oF cle stoßa ge CasseS.
Theie age 4 Stoéoge Cla SSes as
1) AuFo
2 Bgis fet
3]exteen.
4) Sta tic

evee Stoéaqe clasSes


as ed On the et
5 4hinS claSsIFied
claSsiFied
heke h e S
2 what memoey get qlloca ted.
the defaul Va Value
ue of vcé
Voe iable
abl
Ohat hat
Oha is theope OF ti
tha yatiab|e
Vaeiable. e me 1 dhat
5
ohajiSJhe
Jaeiale. linkage of hat
hat
Date
Page

ConSld ef
all he
he
belotdJable hich demonsis
Con Cept of Sfofage Clas ses
epend
aSed Aulo
(Loc0)
EegisteE ex1eEnSta tic
ata memoEyallocation
Pata
Data
ta FiC 6 fack
CPU DATA Le5S Stati c
sqmen Heqion
Regis1 INon BS)segm en
ol 0-01 Default value Gafba qe Gaebaqe |O]0.0 16|O-0
rhHougpol Ft e s Cope BloCk htoughout
glockPEb
the-lock
Therug houLfe timne Theoughoutthoughout hêoughouh fough
he Peogumy dhe funcH on functtbn the peog &am
PEo
To NO Exeena No
nc
EnKage

'Aufo 5fofa qe Class


Auto S default S toea ge clasS oF eve
eveey
LoCal Vaeiable.

le
ASTt 15 default Stoeage clasS Weithng
T
autokeydoedS optibnal
he
Veeiable
to6 he auto
memo6Y tack FSeme. OF
allbcafed n he
9ets Fun cHon.
padtiCulae
he
inside
he a1abe S
5 (ope 1n wh 1ch

bloCK L FunCH on
h e
is efine
tifetme C he cruo Uafiable 5 insi
15ins
he
he function means hen Ne wlen
FEomthe function. memoey 4e1s declloca
o Catoe
dutb mo tically

We Cont acceSS he auo Vatiable


cufstde he blocK ue .to h 1Ch LinK
iS ConSide aS no LinKoge

Reislee Stoeoqe closS


Regishe sBotage clasS is feques

Due to Regis Stosage claSS_


the memoE Fo e
Vaeiab le|
ets alloca te inSide the PO
Regis ee diEe otH
Due o Ohich tde Carn cCCe
$hat Voeioble n Tosje st a
Dthe han sthe
MemDE Locatton

ethee n j S e
Rad sanme ihe aatto
o stos

class
Date
Pane

LImitafton Of Registet SlofagecloSs

Rcgisteg stosage cla[s 1S Reques


TE The Sufficien CPU Re gis E_aep
avail abedhen dhe Regysteg Sfo8aq2e
ClaSS get applic ble othes1Se the a

oefault Sto8age clasS get applied1e


auto We Can+ chekk
AS a Peogfammee

Weath ef e RegiSteg get allo cated of


not.
Reqisteg Stosaqe claSs
eneSally The
¬o8 c h e e 4
int
is onlyN aPric bje'

dolo ype
Regisje Sto6age class is
TF he Fetch add BeSs
fhen Cant
aPpliCoble o Ohich pointee
that Vaeia b le.LDeu
e noF appliCable].

not aplicable
applicable
ape
clasS
Registek Sto&age Onion etC.
sfeuctuee

aSea
s R e g i s t e g s t o é o q e

We Cant use ab lp
he globeQ
class To8
Date

StaHC o8oge class


SlahC
hele t0 0 fypes oF
ClasSeS aS OCaR
Sto08 ge
Statjc
Static

Sta Hc 1s a5}atic abioble


tohfch is defined nside
he unction
GlobeQ Sfofic Such aStatic
Uoefable Ohich s define ut Side
heFuncHon
Cae StatiC
get alloca ted 6t06age. classe Menlo
Ohich is p cap of dd ta
Sechon
F We 0de
the Shatic
dher ehe Value LoccO Vasrab/e
0f h Uak rab/e
pEeSetVed aceoSS the
unctOn

The efault Ualue 0 5}otic e


IQ0 08 0O able
The iseime
S}atic
dhêou qh Out dhe reog Eam StoEoge clasS
Data
Page

eAn Stofoge laSS

exteen is Conside aS dhe Subs 6n


OFF dhe exteena
Keypoed
T Oue PEogeam iS divided
mulliple Files dhen TO a CCe sS dhe
Valiable 8om one 7e o anothe File
We have vo uSe exteen Keynoed.
When uSe dhe extees keywoe
IS Consideked aSdhe
Jhe declea
decleato
a Vaiable ftonn ofof
Decl8aton OF
v etl able;
1whete theie Decleq tion e aAbe
S no IS PoS itim
dhat yadiobe but memosy allocatio Foe
Data Pe ge Only he
name
Definatfon dslose .
Vatiable
memo8 TiS he
pla Ce
Fo8 he
Vab)egFS hgllocated
eee
t that
he Vaeioble Point We
we Con
(an Dto tE
ConSidet h e
Ohich belbd
Con ains the fe Pf og eqm
s.C Second c
tatic Globl
tafic Glabal is dhe Subrast ofr
Static SfoFage cla5S.
Tn case OF noEmal globc Vagiable
Can access the Value Feo One.FiIe
We
We
dnothe8 Fe. usfng the exteen KeyneEd
to
TO Sesieict dhe uSe
Tt We ant
OF lobal Vatia ble tsom ne le
to USe he
to File. we have
anotheeE
Con CeTPE OF Global Static
lob ae Vagiable is slatiC Valable
I F Oue tho Vafia b1e
We
Cant aCcess
then th extekn
anothe e dSing
nto
Key doE
uSe OF rlo be S jatic vcable
The Volue iKe
+o PEeSefvet he
Snot
S tattc Vaeiabe
Lo ca

he abov cnCeT
Same n
execdel
@ualifieE Page
Da ta Type

COhich
a ConCep
Cualifie

nens
1S
@udllty
TO
an existing
c1able
ype Qualifi
Thei8 at
2).Volotie
Con SF

tonSt n Cctto

W hen ne use Consp keywos


oFthe Vaeiab]e w e Cam
Change he alue oF hat Vabiable
Const Viable S Such C Voio
hó Se Válue EemainS ConS fan H h 8ougm
heoug
Ou heexicu Hon OF he
Eog Sam
weiTS to Chanc e th e
Value. he
ee 8o8
ComPie oi aenetat
The
Same Concepan bS
aS aS el) a r
In Java ava but
They USe
nStead 6F
Cons Keyde
Keyo .
ConSldet he belD
no4 iS
S o8maQ XamP|
Constan veiatolex
inclu de <sl d1G h>

int No Jo
(onS} nt No2 J0 60 h64
NOt UAlouw ed
I N2 ++,1Not Allwed 00 6
o 22

eetutn No2 o

204

VDlotile
TF We use Vola tile keywoed we eques
to he Compiles that youhould Auotd
any optimi q}ion Stsajesg Nth tho Peiculat
Vapiable
The oncopt of Vola H e 15 a not

peaticl CugeFuQ in TodaS Compile£


Date
IO C and C +E Page
A EEay

almos Same in
The ConCepof eeay 1s
evety
evee PEoq amminq Lanqu ae
iS ConSideg as detived
A8eaY
is Ceealed om he o heg
dol a pe

do ias |fucfue
8ea
7 188aY
hich
S
holds
cefined as

homoqenouk
aLineak
elemen
whithaet sfoee
SequenaQ and index o6mat

Sfoeing and
ala Data suchute is 1S nay of
he dafa in PaeH Culak
EepfeSenff1n
Foemot
Thei8 ate f0o of oata s {6u ctut
type S
a Lin eae da lo S8uctuee4non-Lineaé
uta Steuc tuee

Such dafa s
Linea dala Sleuctute e
acceSShe elemenf in Line e Passron
which

T8 exam-eAesay Linea Ked iSE, Stack,


Queue etc
Lineae dato sh8ucuee ete da
data
72 Non
e elemenf tn
hich Con
s f uctvte
n o n lineaa ra SSIón
hash tale etc
e Teee
Daie
Pa

int AE e Cs]
T1Ae iS ne
medH o neQ
hich Cont cain S 5 ele ment 4 at &a
C S oF ach lClem
ach
pe nteaE en

A
8 a
membee oitilizadi on
AeLol
AE 2
AsE C2] - 54
As [31- Jo

2
AE 2
200 204 208
5 Lo
212 2 6
220
of
A6 fa
ase AdeECS S
ConStc eg he belo S nlax hh S
used fo C8eae dhe a8q

nt A8Et5J;
is above Syn lax iS definalicn of 68
oS it S
os is Consio ee aS defination memof elsS
Tlocated ctt haB point

he aS
we Can ead a bove Statement

dimentionae at Bay Ohich Confain


ABe 1S One
5 element and each eement iS oF type inieget

Diogeametic Rep6een ajron


Conside he belo
af above

2
54 o
yAee 2 216 20
208
Nme

tf
A@ea Base oddBess

mememoe
to the
above Slax
Due Te hal
We Can in itiali
alloCa ed belou ptax
Cal l e d
C a l l e d

memoEY uin I n a l i zadion


SS

h i s Ype O} n tell7ation
membef
membeeE b
AEet 24

A66C2 51
AFe r_= 10
A6r4

in CaSe df Aefa earh eleme ntoF A6


haS a Oqhe=qndex Onique index
ndex

fncexing
incexing oF Aee Aldas sjast som a

Thei ae e tudo WaS n Whick e Can initilte


Ini

he .aeea membee b mem b e i'nitieliZah


uSec in above e ramPle

membee initaQizoation 1is


in+ BeeS= ,24,5 Lo, LL

TF We
n0izethe ag say
initataton ist then uSi ng membe
Specit he E 15 optiona
SICe
oFhat
ntC8e tJ 1 , 2
5 oA .
TF he menmbeeinlialiealton isl IS no
4hei and Sire o Eeay IS noSpert fied he
Compieg oilgenepaf e Bo6 8eouo (omp! et
unable deide ne Site tht

int De8t]; | Eeeoe

A ddEesS oF opeeatog l 4 j
In Case F Cand Ctt 4 is Consioeg
a dd êeSS OF Opeea to8 hfch gives
vhe ádde eSS oF any Vagia ble that e uSe
i'n ou PEogeam.
The addsess displaced by hS a opea lo8
S add8 ess gene8afed bthe
OPeeotin System
hen we execu}e oue Teogeam multPle
tmeS itoilldis
play diffeeen adde e SS

BecouSe ht add8eSS an Vilsfus| addeess


Dat
Page

Sizeof c) opeeooe
1Suced in Cand c t
uhir
cata Objec Som
ves sice OF
ang
any
FSoqeam
- size oF opesaloe ves

in blees
ConsideF the belou exampe hich emonsenc
Cand

Hinclude <s}è1o h

Int mainC)

Tndiro J; Ch
Chae Ch H/ A
200

petnfCt'value oF ).d n ' no )


Peintfvalueof th lo Cn,ch) A
Peintf Addeess of no is: . U\n' 4no),_ Iloo
2oo
Peintfti AddeeSS of ch is : f. u |n 4chl-
Peiní (Size of no is o l . n SIzedf/n0)
SIZedflno) 1
1
Pein)('sire of ch is: lo ð\n'', size of h]1,

eetno
Date

toemal 6peciiieES

in C ane Ctt ToE mat Speci fveEs as e

Such avafici ble ohich indicotes hich

yPe OF data du want dto i spla


ype oF d t o tYpe a ccept tom OSseë

Considet fhe belo FoEmal SPPCcI fieg


its Mean ing

Siqned int egee in decimae Tofma


chaeace
dato
F
/ 0 U05 igned infegee
l HeadeCiMal a t a
/0 OCta dato
/ P Pointe eepfesentati on
double
Long0ublo

olo5 Seing

200

1
age

Name of A8g IS Intesnally


the base Add Fess OF
Consid eg a
elemenF OF the
nFeI FiESt
TF We Want
to Fetc he add8eSs
heleIS DO need o Se
or
&opPesa to
B using he size
Can a CCeSss
he SiZe ot opeË a to8 Ne
of an a e a
TYPS

imrS

imenSn 45so

I he AEa
hon eleme

the somadng un'nt Te3 Smsn'S

e e fault
at TY c

cuble

c bove Sule ePplicoble

int DSe[
Date
Page

ConSidee the belo example OF


mult OImc
al&o
int Ass[

S One DimenSlonQ Ass


cohi c h
Contai nS elementS
Cach elemenf 1S OT Type in

Ue Can I n I t a I Te
above
memb eg
a98at USIna meN beg
ntial1za t0n
fechn que
AeeL= 20j
ASE [2 36 2
A EE[s=40 Aeeo 160
20
3 4
104 O8 t2

Consideg h ebelod
TWo dimenSion

int bee [3]L«;

bee s Too
e ConFains
DimensioncQ AS8a
3 one
Confains DimeS1onaQ
elemen
and ea h
elemen is
Tye inteqee
Consices he beloS Dageam fic KepESente
hREE [o ,
bee[oJT
beeColr:] 12
bEelol L3) 13;
11
beEL2JLI 10

ConSidee he belo
membeeb me m be3

beelo]
bee CoIC2]=12

bes[2] L o_

double Ass[5] [3),

A66 S TWo OimenGÍona2 6Ea hrh ontn


o n e dimenS onaI AE Ea Con ta

element OF Type Peo oube


Cate
Par

nsic eeiyed ato


Som ond c + TuP
The Cence CFPoin tee 1S
On
Longuoas Ke C ond
apphcable
ctt
ye lona
Suth Longe hiCh
esacve C . s i8eoc+ la
Poine s Consideg oS Vaeiable
StoFes de@eSsS hich

32
each eto
Applicottons a
dd Ees
sej a
Lon Pes
inFege TTPe
The size CF
Loainteae4 7s
Due othe obcve P
Pointee is &bytees site oF
ea Ch
Thee
nd The lecle. modo

nToda oE IeuSo the per


mode WinconNS n don)s 0 , t
Uibntu, moc OS

AT Nhe
OF (Eeotng s
eogeaming Lang 3 72] OS ce n Bea
mode9

exa IP ms DoS DISK opféa tina SSem


T Rea mode OS Theie ale
OF Poinfees
neag pointeg
Fog Pointeg
huge Poinfee

heae Poine S Pointe hirh Pon S n


betn o to 64 K9 oF ae RA

Fc POin e ís Poine hich Poins in

betn 694D to 1024 kB CT RAr

Pon e hic POinS n


huge Poinet 1S
befn 094 k nd onwo 2ds

1 a b le
Such Ype OF PI* no
n Tod@S S Bers e
S e
Sche,
Flo addfessinq RAr

hbabYe
1024
huge poin/eé

cue Pointeg AK tol024K

neat Poin fe

tO640KB
Xomle

nno J

inl p - n o

20t

dhe a bove Sntax 4 OpeRaio6


etch +he addeeSS
nd Stoe (+)

Fect h dhe dote Theough the Pointe

We Can ead he a bove

al

P is Poineg hich hol ds


Ihleget, CuEBently t holdS d
whelo no is VAIOb/le CF Tvoe tge
Initializred dhe Value to Hh Phe
Considet he beloN Sy
RPSult
N

You might also like