Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

class

member

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.

like image 285
CodeRider Avatar asked Mar 22 '13 10:03

CodeRider


1 Answers

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.

like image 143
R. Martinho Fernandes Avatar answered Sep 17 '22 23:09

R. Martinho Fernandes