Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:39:35+00:00 2026-05-27T11:39:35+00:00

I was wondering what the size limit for a class is. I did a

  • 0

I was wondering what the size limit for a class is. I did a simple test:

#define CLS(name,other) \
class name\
{\
public: \
name() {};\
   other a;\
   other b;\
   other c;\
   other d;\
   other e;\
   other f;\
   other g;\
   other h;\
   other i;\
   other j;\
   other k;\
};

class A{
   int k;
public:
   A(){};
};

CLS(B,A);
CLS(C,B);
CLS(D,C);
CLS(E,D);
CLS(F,E);
CLS(G,F);
CLS(H,G);
CLS(I,H);
CLS(J,I);

It fails to compile with

“‘J’ : class is too large”

If I remove the final declaration – CLS(J,I);, it all compiles fine.

Is this a compiler-imposed restriction, or is it somewhere in the standard?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:39:36+00:00Added an answer on May 27, 2026 at 11:39 am

    In C++11 this is Annex B. Implementations can impose limits, but they should be at least:

    • Size of an object [262 144].
    • Data members in a single class [16 384].
    • Members declared in a single class [4 096].

    The third one isn’t directly relevant to the kind of construction you’re using, I mention it just because it indicates that the second one is indeed the total members, presumably including those in bases and I’m not sure about members-of-members. But it’s not just about the members listed in a single class definition.

    Your implementation appears to have given up either 2^31 data members, or at size 2^32, since it accepts I but not J. It’s fairly obviously reasonable for a compiler to refuse to consider classes with size greater than SIZE_MAX, even if the program happens not to instantiate it or use sizeof on the type. So even with the best possible effort on the part of the compiler I wouldn’t ever expect this to work on a 32 bit implementation.

    Note that “these quantities are only guidelines and do not determine compliance”, so a conforming implication can impose an arbitrary smaller limit even where it has sufficient resources to compile a program that uses larger numbers. There’s no minimum limit for conformance.

    There are various opportunities in the C++ standard for a conforming implementation to be useless due to ridiculously small resource limits, so there’s no additional harm done if this is another one.

    C++03 is more-or-less the same:

    • Size of an object [262 144].
    • Data members in a single class, structure, or union [16 384].
    • Members declared in a single class [4 096].
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if there is a limit to the size of a single
I am wondering is there any way we can test the font size/color of
I am wondering is there a size limit for array in php 5? I
I am wondering does the size() function returns an internal stored variable (which gives
I was wondering if it is possible to declare an array (size not known
I was wondering how to initialise an integer array such that it's size and
I've got RGB values stored in a GLubyte array of size 3 and wondering
Hey, I'm just wondering what code I could use to auto change the size
I'm wondering if there's a way to determine the size of my svn repo
I'm wondering how I can manipulate the size of strip text in facetted plots.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.