C# 0 The Complete Reference


PART I C h a p t e r   1 1



Download 4,07 Mb.
Pdf ko'rish
bet357/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   353   354   355   356   357   358   359   360   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   1 1 :  

I n h e r i t a n c e  

271


PART IPART I

The output from this program is shown here:

Info for t1:

Triangle is isosceles

Width and height are 4 and 4

Area is 8

Info for t2:

Triangle is right

Width and height are 8 and 12

Area is 48

The

Triangle

 class creates a specific type of 



TwoDShape

, in this case, a triangle. The 



Triangle

 class includes all of 



TwoDShape

 and adds the field 



Style

, the method 



Area( )

, and 


the method 

ShowStyle( )

. A description of the type of triangle is stored in 



Style

;

Area( )

computes and returns the area of the triangle; and 

ShowStyle( )

 displays the triangle style.

Notice the syntax that 

Triangle

 uses to inherit 



TwoDShape

:

class Triangle : TwoDShape {



This syntax can be generalized. Whenever one class inherits another, the base class name 

follows the name of the derived class, separated by a colon. In C#, the syntax for inheriting 

a class is remarkably simple and easy to use.

Because


Triangle

 includes all of the members of its base class, 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   353   354   355   356   357   358   359   360   ...   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