官术网_书友最值得收藏!

How it works...

While the example illustrated earlier is a rather simplistic one, the theory is sound. The abstract class takes collective functionality across all cats and groups so that it can be shared inside each derived class. No implementation exists in the abstract class; it only defines what needs to happen. Think of abstract classes as a type of blueprint for classes that inherit from the abstract class.

While the content of the implementation is up to you, the abstract class requires that you add the abstract methods it defines. From here on, you can create a solid foundation for similar classes in your applications that are supposed to share functionality. This is the goal of inheritance. Let's recap the features of an abstract class:

  • You can't instantiate an abstract class with the new keyword.
  • You can only add abstract methods and accessors to an abstract class.
  • You can never modify an abstract class as sealed. The sealed modifiers prevents inheritance, while abstract requires inheritance.
  • Any class derived from your abstract class must include the implementations of the abstract methods that were inherited from the abstract class.
  • Because abstract methods inside the abstract class have no implementation, they don't contain a body either.
主站蜘蛛池模板: 延安市| 西林县| 邹平县| 嘉定区| 贵南县| 瑞昌市| 石嘴山市| 广昌县| 威远县| 昭苏县| 银川市| 天祝| 金寨县| 武胜县| 麻江县| 沙湾县| 崇文区| 讷河市| 栾川县| 新蔡县| 景德镇市| 扎囊县| 射洪县| 佛山市| 蓬安县| 高邮市| 宝应县| 疏附县| 六盘水市| 广东省| 明水县| 离岛区| 湘乡市| 鄂尔多斯市| 乌拉特前旗| 榆中县| 延津县| 阳泉市| 汉寿县| 涿鹿县| 柏乡县|