What is the maximum number of members a class can have in C ++

Please take this question as a question of curiosity.

I just want to know that there is a limit to the number of members that a class can have in C ++. I hope that there will be some kind of maximum permissible number, since everything will be finite in the language that I assume.

+6
source share
1 answer

This value is determined by each implementation. The C ++ Standard recommends some of the minimum supported values ​​in Appendix B:

- Data elements in one class [16 384].

[...]

- Direct and indirect base classes [16 384].

- Direct base classes for one class [1,024].

- members declared in the same class [4 096].

- The final redefinition of virtual functions in the class, available or not available [16 384].

- Direct and indirect virtual databases of the class [1,024].

- Static class members [1,024].

The minimum for "members declared in one class" is less than for "data members in one class", because classes can inherit data members from their databases.

+8
source

All Articles