Reputation: 1814
Please take this query as a question of curiosity.
I just want to know that is there any limitation in the number of members a class can have in c++. Hope there will be some maximum allowed number since everything will be finite in a language I guess.
Upvotes: 6
Views: 3667
Reputation: 234484
That value is defined by each implementation. The C++ standard recommends some minimum supported quantities in Annex B:
— Data members in a single class [16 384].
[...]
— Direct and indirect base classes [16 384].
— Direct base classes for a single class [1 024].
— Members declared in a single class [4 096].
— Final overriding virtual functions in a class, accessible or not [16 384].
— Direct and indirect virtual bases of a class [1 024].
— Static members of a class [1 024].
The minimum for "members declared in a single class" is less than the one for "data members in a single class" because classes can inherit data members from their bases.
Upvotes: 8