Download presentation
Presentation is loading. Please wait.
1
Classes and Inheritance
靜宜大學資工系 蔡奇偉副教授 ©2011
2
大綱
3
Class Inheritance Base Class Derived Class
5
Accessing the Inherited Members
6
All Classes Are Derived from Class object
7
Hiding Members of a Base Class
10
Base Access keyword base
11
Using References to a Base Class
An instance of a derived class consists of an instance of the base class, plus the additional members of the derived class. A reference to the derived class points to the whole class object, including the base class part. If you have a reference to a derived class object, you can get a reference to just the base class part of the object by casting the reference to the type of the base class by using the cast operator. The cast operator is placed in front of the object reference and consists of a set of parentheses containing the name of the class being cast to.
13
Virtual and Override Methods
16
Constructor Execution
17
Constructor Initializers
18
use a different constructor from the same class
19
Class Access Modifiers
20
Inheritance Between Assemblies
22
Member Access Modifiers
23
Regions Accessing a Member
24
Public Member Accessibility
25
Private Member Accessibility
26
Protected Member Accessibility
27
Internal Member Accessibility
28
Protected Internal Member Accessibility
29
Summary of Member Access Modifiers
30
Abstract Members An abstract member is a function member that is designed to be overridden.
31
Comparing Virtual and Abstract Members
32
Abstract Classes
35
Sealed Classes
36
Static Classes A static class is a class where all the members are static. Static classes are used to group data and functions that are not affected by instance data. A common use of a static class might be to create a math library containing sets of mathematical methods and values.
37
Extension Methods
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.