- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 204字
- 2021-07-03 00:11:58
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.
推薦閱讀
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- Python高級(jí)編程
- Python Geospatial Development(Second Edition)
- Blender 3D Incredible Machines
- SSM輕量級(jí)框架應(yīng)用實(shí)戰(zhàn)
- Swift細(xì)致入門與最佳實(shí)踐
- 批調(diào)度與網(wǎng)絡(luò)問題的組合算法
- Go語言精進(jìn)之路:從新手到高手的編程思想、方法和技巧(2)
- App Inventor創(chuàng)意趣味編程進(jìn)階
- Learning Material Design
- Unity 2018 Augmented Reality Projects
- C++程序設(shè)計(jì)教程(第2版)
- 深入淺出Python數(shù)據(jù)分析
- 深度學(xué)習(xí)入門:基于Python的理論與實(shí)現(xiàn)
- Java程序設(shè)計(jì)實(shí)用教程(第2版)