Download presentation
Presentation is loading. Please wait.
Published byBrianna French Modified over 9 years ago
1
計算機程式 第十三單元 Inheritance 授課教師:廖婉君教授 【本著作除另有註明外,採取創用 CC 「姓名標示 -非商業性-相同方式分享」台灣 3.0 版授權釋出】創用 CC 「姓名標示 -非商業性-相同方式分享」台灣 3.0 版 本課程指定教材為 C++ How to Program, 7/e, Harvey M. Deitel and Paul J. Deitel, both from Deitel & Associates, Inc. © 2010 。 本 講義僅引用部分內容,請讀者自行準備。 1 本作品轉載自 Microsoft Office 2007 多媒體藝廊,依據 Microsoft 服務合約及著作權法 第 46 、 52 、 65 條合理使用。 Microsoft 服務合約
2
An Overview Create new class from existing class o Base class vs. derived class o Absorb base class’s data and behavior o Enhance with new capabilities More specialized group of objects Behaviors inherited from base class Additional and customized behavior Three types of inheritance o Public, protected, and private 2 Derived Class: Car Base Class: Vehicle
3
An Overview (cont.) Base classes and derived classes o Object of one class “is an” object of another class o Base class typically represents a larger set of objects than derived class Example: o Base class: vehicle Includes cars, trucks, boats, bicycles, etc. o Derived class: car Smaller, more-specific subset of vehicle 3
4
Class Hierarchy Direct base class o Inherited explicitly (one level up hierarchy) Indirect base class o Inherited two or more levels up hierarchy Single inheritance o Inherits from one base class Multiple inheritance o Inherits from multiple base classes Base classes possibly unrelated 4
5
Class Hierarchy (cont.) 5 CommunityMembe r EmployeeStudentAlumnus FacultyStaff AdministratorTeacher AdministratorTeacher Single inheritanc e Multiple inheritanc e
6
Outline Commission Employee.h 6 p.527-528
7
Outline Commission Employee.cpp 7 p.528-530
8
Outline fig12_06.cpp 8 p.531
9
Outline BasePlus Commission Employee.h 9 p.532-533
10
Outline BasePlus Commission Employee.cpp 10 p.533-535
11
Outline fig12_09.cpp 11 p.536
12
Outline BasePlus Commission Employee.h 12 p.538
13
Outline BasePlus Commission Employee.cpp 13 p.538-540
14
Outline Commission Employee.h 14 p.542-543
15
Outline Commission Employee.cpp 15 p.543-545
16
Outline BasePlus Commission Employee.h 16 p.545-546
17
Outline BasePlus Commission Employee.cpp 17 p.546-547
18
Outline Fig12_16.cpp 18 p.547-548
19
Outline Commission Employee.h 19 p.550
20
Outline Commission Employee.cpp 20 p.551-552
21
Outline BasePlus Commission Employee.h 21 p.553
22
Outline BasePlus Commission Employee.cpp 22 p.553-554
23
Outline Commission Employee.h 23 p.557-558
24
Outline Commission Employee.cpp 24 p.558-560
25
Outline BasePlus Commission Employee.h 25 p.560-561
26
Outline BasePlus Commission Employee.cpp 26 p.561-562
27
Outline fig12_26.cpp 27 p.563-564
28
版權聲明 28 頁碼作品版權圖示來源 / 作者 1-29 本作品轉載自 Microsoft Office 2007 多媒體藝廊,依據 Microsoft 服務合約及著作權法第 46 、 52 、 65 條合理使用。 2 Open Clip Art Library ,作者: TheresaKnott ,本作品轉載自: http://openclipart.org/detail/810/boeing-b47e-by-theresaknott ,瀏覽日期: 2013/1/16 。 http://openclipart.org/detail/810/boeing-b47e-by-theresaknott 2 Open Clip Art Library ,作者: netalloy ,本作品轉載自: http://openclipart.org/detail/76801/royal-motorcycle-by-netalloy ,瀏覽日期: 2013/1/16 。 http://openclipart.org/detail/76801/royal-motorcycle-by-netalloy 2 Open Clip Art Library ,作者: Anonymous ,本作品轉載自: http://openclipart.org/detail/23878/blue-bike-by-anonymous-23878 ,瀏覽日期: 2013/1/16 。 http://openclipart.org/detail/23878/blue-bike-by-anonymous-23878 2 Open Clip Art Library ,作者: Machovka ,本作品轉載自: http://openclipart.org/detail/2827/yellow-car-by-machovka ,瀏覽日期: 2013/1/16 。 http://openclipart.org/detail/2827/yellow-car-by-machovka
29
版權聲明 29 頁碼作品版權圖示來源 / 作者 4 Open Clip Art Library ,作者: Gerald_G ,本作品轉載自: http://openclipart.org/detail/57433/man-face-cartoon-by-gerald_g-57433 , http://openclipart.org/detail/57433/man-face-cartoon-by-gerald_g-57433 瀏覽日期: 2013/1/16 。 4 Open Clip Art Library ,作者: Gerald_G ,本作品轉載自: http://openclipart.org/detail/57427/man-face-cartoon-by-gerald_g-57427 , http://openclipart.org/detail/57427/man-face-cartoon-by-gerald_g-57427 瀏覽日期: 2013/1/16 。 4 Open Clip Art Library ,作者: Gerald_G ,本作品轉載自: http://openclipart.org/detail/57403/man-face-cartoon-by-gerald_g-57403 , http://openclipart.org/detail/57403/man-face-cartoon-by-gerald_g-57403 瀏覽日期: 2013/1/16 。 5 C++ How to Program, 7/e ,作者: Harvey M. Deitel and Paul J. Deitel , 出版社: Deitel & Associates ,出版日期: 2010 , P.524 。 依據著作權法第 46 、 52 、 65 條合理使用。 6-27 Open Clip Art Library ,作者: aritztg ,本作品轉載自: http://openclipart.org/detail/3422/mouse-by-aritztg ,瀏覽日期: 2013/1/10 。 http://openclipart.org/detail/3422/mouse-by-aritztg
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.