问题描述
关于c ++的问题
为什么类定义中的最少数据成员是零
我认为它应该是一个,即指向虚拟表定义的指针非常感谢。
一个没有用于继承层次结构的数据成员的类。
基类只能有几个 typedef
在多个类中使用。例如, std :: iterator
类模板只是定义了标准类型,因此不需要在每个迭代器类中定义它们。
一个接口类通常没有数据成员,只有virtual成员函数。
一个虚拟表与数据成员无关一个类。
question about c++why minimal number of data members in class definition is zero
i think it should be one , i.e pointer to virtual table defined by compiler
thanks a lot
It is often useful to have a class with no data members for use in inheritance hierarchies.
A base class may only have several typedef
s that are used in multiple classes. For example, the std::iterator
class template just has the standard types defined so that you don't need to define them in each iterator class.
An interface class typically has no data members, only virtual member functions.
A virtual table has nothing to do with the data members of a class.
这篇关于为什么C ++类允许有零个数据成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!