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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:34:10+00:00 2026-05-22T15:34:10+00:00

struct A { enum E { FIRST, SECOND }; }; struct B { typedef

  • 0
struct A
{
    enum E
    {
        FIRST,
        SECOND
    };
};

struct B
{
    typedef A::E E;
};

int main()
{
    B::E e0 = A::FIRST;//OK (this case is clear for me)
    B::E e1 = A::E::FIRST;//OK (this case is clear for me as well)
    B::E e2 = B::FIRST;//Compile Error: FIRST is not member of B (Why isn't this allowed? Don't we lose meaning of typedef of enums in this case?)
    B::E e3 = B::E::FIRST;//Error of compiler (If there were no bug in visual studio 2005 compiler, would this code work?)
    return 0;
}

P.S. The question in code.

Update: Actually the bug is fixed in VS2010.

  • 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-22T15:34:11+00:00Added an answer on May 22, 2026 at 3:34 pm

    After adding the missing semicolon in B::E e3 = B::E::FIRST, the following holds:

    In C++03, only the first line (B::E e0 = A::FIRST;) is correct, the other three are errors:

    B::E e1 = A::E::FIRST; // error: ‘A::E’ is not a class or namespace
    B::E e2 = B::FIRST; // error: ‘FIRST’ is not a member of ‘B’
    B::E e3 = B::E::FIRST; // error: ‘B::E’ is not a class or namespace
    

    In C++0x, only the second line (B::E e2 = B::FIRST;) is an error (FIRST is still not a member of B!), the other three are correct.

    Not an answer to the “why?”, just pointing out that there are two different issues at hand. The rationale for the issue that affects e1 and e3 is probably explained in the C++0x working papers.

    The change was to the first sentence of 3.4.3[basic.lookup.qual]/1 which now says

    The name of a class or namespace member or enumerator can be referred to after the :: scope resolution operator

    But it used to say

    The name of a class or namespace member can be referred to after the :: scope resolution operator

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

Sidebar

Related Questions

No related questions found

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.