C# 0 The Complete Reference


x2  can’t  access b



Download 4,07 Mb.
Pdf ko'rish
bet383/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   379   380   381   382   383   384   385   386   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

x2

 can’t 


access

b

 even when it refers to a 



Y

 object. This makes sense because the base class has no 

knowledge of what a derived class adds to it. This is why the last line of code in the program 

is commented out.

Although the preceding discussion may seem a bit esoteric, it has some important 

practical applications. One is described here. The other is discussed later in this chapter, 

when virtual methods are covered.

An important place where derived class references are assigned to base class variables 

is when constructors are called in a class hierarchy. As you know, it is common for a class 

to define a constructor that takes an object of its class as a parameter. This allows the class to 

construct a copy of an object. Classes derived from such a class can take advantage of this 

feature. For example, consider the following versions of 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   379   380   381   382   383   384   385   386   ...   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