C# 0 The Complete Reference


Stack  constructor. The  tos



Download 4,07 Mb.
Pdf ko'rish
bet239/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   235   236   237   238   239   240   241   242   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Stack

 constructor. The 



tos

 member holds the index of the top of the stack.

Both the 

tos

 and 


stck

 members are private. This enforces the last-in, first-out stack 

mechanism. If public access to 

stck

 were allowed, then the elements on the stack could 

be accessed out of order. Also, since 

tos

 holds the index of the top element in the stack, 

manipulations of 

tos

 by code outside the 



Stack

 class must be prevented in order to avoid 

corruption of the stack. Access to 

stck

 and 


tos

 is available, indirectly, to the user of 



Stack

through the various public methods described shortly.

The stack constructor is shown next:

// Construct an empty Stack given its size.

public Stack(int size) {

  stck = new char[size]; // allocate memory for stack

  tos = 0;

}

www.freepdf-books.com




170

 

P a r t   I :  



T h e   C #   L a n g u a g e

The constructor is passed the desired size of the stack. It allocates the underlying array and 

sets


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   235   236   237   238   239   240   241   242   ...   1096




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish