C.126: An abstract class typically doesn't need a constructor
C.126:抽象类通常不需要构造函数
Reason(原因)
An abstract class typically does not have any data for a constructor to initialize.
抽象类通常不包含任何需要构造函数初始化的数据。
Example(示例)
代码语言:javascript
复制
???
Exception(例外)
A base class constructor that does work, such as registering an object somewhere, may need a constructor.
执行某些动作的基类的构造函数,例如将对象登录到某处,可能还是需要的。
In extremely rare cases, you might find it reasonable for an abstract class to have a bit of data shared by all derived classes (e.g., use statistics data, debug information, etc.); such classes tend to have constructors. But be warned: Such classes also tend to be prone to requiring virtual inheritance.