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

The Archive Base Latest Questions

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

from the below question i sort of get how enums and namespace scoping works

  • 0

from the below question i sort of get how enums and namespace scoping works

Scope resolution operator on enums a compiler-specific extension?

However with regard to test code below i’m confused as to why in the below code snippet:

1) i can refer to return type in function signature as test_enum::foo_enum

2) however “using namespace test_enum::foo_enum” is not allowed

namespace  test_enum { 

   enum foo_enum { 

      INVALID, 
       VALID
    };
} 

// Case 1) this is allowed 
test_enum::foo_enum getvalue() {

     return test_enum::INVALID;

}

//Case 2) is not allowed 

using namespace test_enum::foo_enum; 

is there a particular reason for not allowing case 2 ?
Also are “enums” more of C style construct and better to avoid in C++ code ?

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

    The reason using namespace test_enum::foo_enum; is not allowed is because foo_enum is not a namespace, it is an enum. What works is using test_enum::foo_enum;

    I believe what you are trying to do is something like this:

    namespace foo_enum {
        enum foo_enum_t {
            INVALID,
            VALID,
        };
    }
    
    using foo_enum::foo_enum_t;
    

    This allows you to throw around foo_enum_t freely, but you still have to type out foo_enum::INVALID or foo_enum::VALID

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

Sidebar

Related Questions

My question is sort of a follow on from this question below but I
This is with reference to the below question: Execute program from within a C
Below is a question from Kathy & Bert Bates SCJP 5 preparation CD. I
How to get private key in string from below... key = paramiko.RSAKey.generate(1024) ssh_key =
I want to get the content of a list in a webpage from below
I am wondering how to get the Json value ?(from below JSOn I would
Ok i know this is sort of a non specific question but i am
From below array i want the value of _sql to be displayed or we
i need Enumarable value from below class but give error public static Enumerable LoadDataByName(string
I am getting available memory from below method: static void print_free_memory () { float

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.