Limit of multiple inheritance in C++

不问归期 提交于 2019-12-04 17:52:01

问题


What is the limit of multiple inheritance in C++? i.e, how many classes can a class inherit from? Is it implementation dependent or is there a constraint placed on the number of classes you can inherit from in multiple inheritance?


回答1:


It's implementation defined. C++11 gives recommended minimums in the Implementation quantities section of the standard:

— Direct and indirect base classes [16 384].
— Direct base classes for a single class [1 024].
[...]
— Direct and indirect virtual bases of a class [1 024].

I'd say that's pretty generous.




回答2:


Per §10.1:

1 A class can be derived from any number of base classes. [Note: The use of more than one direct base class is often called multiple inheritance. —end note ]

Everything else depends on compiler's implementation and limitations.



来源:https://stackoverflow.com/questions/20405321/limit-of-multiple-inheritance-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!