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 6719471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:05:49+00:00 2026-05-26T09:05:49+00:00

In the following example, will the size of array v guaranteed to be 2

  • 0

In the following example, will the size of array v guaranteed to be 2 or 3?

static const int i = 3;

class X {

    char v[i];
    static const int i = 2;
};

From the standard,

3.3.6/2 A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in the completed scope of S

I think this means ‘i’ shall be 2 and what does the re-evaluation thing really means here?

  • 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-26T09:05:50+00:00Added an answer on May 26, 2026 at 9:05 am

    The correct behavior is that it should cause an error because re-evaluation would change the meaning:

    Example from section 3.3.6:

    The potential scope of a declaration that extends to or past the end of a class definition also extends to the regions defined by its member definitions, even if the members are defined lexically outside the class (this includes static data member definitions, nested class definitions, member function definitions (including the member function body and, for constructor functions (12.1), the ctor-initializer (12.6.2)) and any portion of the declarator part of such definitions which follows the identifier, including a parameter-declaration-clause and any default arguments (8.3.6). [Example:

    The example is similar to yours (using enum instead of a static const int):

    typedef int  c;
    enum { i = 1 };
    class X {
        char  v[i];    // error: i refers to ::i
                       // but when reevaluated is X::i
        int  f() { return sizeof(c); } // OK X::c
        char  c;
        enum { i = 2 };
    };
    

    At the time v[i] is encountered, the compiler only knows about enum { i = 1 }; (or static const int i = 3;, but when the full class declaration is known, char v[i] would be different because i would be re-evaluated to 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the following example should I expect that values.size() will be called every time
I need a regex that will give me the following results from each example
From the mysql certification guide's example questions ... question Will the following SQL statement
I have the following example in C: int x = 123; size of int
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)
Consider the following C++ code example: int array_1[] = {5,6,7}; int array_2[] = {6,7,8,9};
From here: http://heanet.dl.sourceforge.net/project/teamlab/TeamLabinstall_EN.pdf For a mid-size portal it will be sufficient to deploy it
Example: Suppose in the following example I want to match strings that do not
Given the following example, why do I have to explicitly use the statement b->A::DoSomething()
Let me use the following example to explain my question: public string ExampleFunction(string Variable)

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.