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?
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.
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