c# 第四课 类的更多内容

与类密切相关的几个特征便是继承,多态和封装了,继承

inheritance
The specialization relationship is typically implemented using inheritance.
Polymorphism(多态):  There are two powerful aspects to inheritance.
One is code reuse.
The second is polymorphism(many-forms).
在父类中定义的虚函数,可以在子类中被重写。override是必要的。
Limitations of Abstract
Abstract does force all the derived classes to implement the method, but nothing forces the derived derived classes to implement its own DrawWindow() method.
Sealed 类(完全不允许派生), 防止偶然继承。与Abstract类(用来派生)正相反。
Sealed class 中不能创建新的Protected成员。
posted @ 2015-04-07 12:50  郭松  阅读(106)  评论(0编辑  收藏  举报