C# 0 The Complete Reference


Controlling Access: A Case Study



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

Controlling Access: A Case Study

To better understand the “how and why” behind access control, a case study is useful. One 

of the quintessential examples of object-oriented programming is a class that implements a 

stack. As you probably know, a 



stack

 is a data structure that implements a last-in, first-out 

list. Its name comes from the analogy of a stack of plates on a table. The first plate on the 

table is the last one to be used.

A stack is a classic example of object-oriented programming because it combines storage 

for information along with the methods that access that information. Thus, a stack is a 



data

engine

 that enforces the last-in, first-out usage. Such a combination is an excellent choice for 

a class in which the members that provide storage for the stack are private, and public methods 

provide access. By encapsulating the underlying storage, it is not possible for code that uses 

the stack to access the elements out of order.

A stack defines two basic operations: 



push

 and 


pop.

 A push puts a value onto the top of 

the stack. A pop removes a value from the top of the stack. Thus, a pop is consumptive; once 

a value has been popped off the stack, it has been removed and cannot be accessed again.

The example shown here creates a class called 

Stack

 that implements a stack. The 

underlying storage for the stack is provided by a private array. The push and pop operations 

are available through the public methods of the 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   232   233   234   235   236   237   238   239   ...   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