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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:21:57+00:00 2026-05-24T20:21:57+00:00

Is there a point of doing somthing like this: namespace status{ enum status{ ok,

  • 0

Is there a point of doing somthing like this:

namespace status{
  enum status{
    ok,
    error
  };
}

and use it like that status::ok

Or should i do this:

enum status{
  status_ok,
  status_error
};

and use it like this status_ok?

Update:
With C++11 you now should do this:

enum class status {
    ok,
    error
};

and use like this: status::ok

  • 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-24T20:21:58+00:00Added an answer on May 24, 2026 at 8:21 pm

    I personally don’t like the second variation because the status_ part seems redundant to me. The former version avoids that problem, but having a type status::status looks strange too. Furthermore, a namespace is open to modification, so in case somebody did something like

    namespace status {
      void error( const char *msg );
    }
    

    You would get a compiler error since the function error clashes with your enum value.

    I prefer to use a third variation:

    struct MouseButton {
      enum Value {
        Left, Middle, Right
      };
    };
    

    This lets me write functions like

    void handleMouseButton( MouseButton::Value b ) {
      switch ( b ) {
        case MouseButton::Left:   // ...
        case MouseButton::Middle: // ...
        case MouseButton::Right:  // ...
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in a C++ program, there is a point when it reads a string like:
There are a set of point that are collinear. The problem is to add
I would like to do something like this: chroot /mount-point /path/to/script $var1 $var 2
This is my first try trying to use WCF, so I'm guessing I'm doing
I have an activity that has properties that look something like this (they're set
I've got a database that looks like this: ID Name ParentID 1 1 0
im new to jQuery and searching a way for doing smthing like this: I
Is there a way to change what THIS point to? class foo{...} foo* fooinstance
Update & Summary I feel obligated to make this question clearer, now that there
For example in C# or in JavaScript documents. If not, is there point in

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.