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

  • Home
  • SEARCH
  • 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 7796889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:30:36+00:00 2026-06-01T23:30:36+00:00

I am confused about how enums work with classes.. Here is my test code…

  • 0

I am confused about how enums work with classes..

Here is my test code… yes I know it doesn’t work…
http://ideone.com/oy3VH

Basically I have the test functions working… Testing2 and 3 are the same function, I only made them to for example purposes.

My confusion lies with “testing3”. What I wish to do is access the switch statement by calling the object with a human readable value. like PlayAgain, or Instructions.

Now as you can see in line 79, this works.. but ONLY if declare the enume in main (or the w/e scope I call the object….

What I would like to do is WITHOUT a 2nd declaration use the enume name.. as in line 82?

Is that possible .. and if so how?

Thanks

  • 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-06-01T23:30:38+00:00Added an answer on June 1, 2026 at 11:30 pm

    You need to scope your enums when using them outside of the class itself.

    eg:

    Func( cEnumtest::PlayAgain );
    

    some other tips:

    your enums are essentially integer constants. I suggest you have a naming convention that differentiates them from other code strictly for code-readability and clairty’s sake.

    eg: (‘k’ stands for constant ; ‘c’ would normally be used to indicate a class data type so that’s why ‘k’ 🙂

    enum eGameActions
    {
        kActionPlay,
        kActionQuit,
        kActionSaveGame
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm confused about this bit of code from the HTTP package : type HandlerFunc
I am really confused about object relationships! I have two classes Person and Address.
I'm a bit confused about the right way to write a code. I read
I'm a bit confused about the whole idea of IO; I want to know
originally i was using a .net sdk for facebook found here: http://facebooktoolkit.codeplex.com/ but now,
Totally confused about the data types required here. I have this Linq statement: var
Very confused about this one. This code in views.py works, but only when I'm
Really confused about what's going on here. I have a class defined as follows:
I am confused about class size of these two classes. who can tell me
I'm a bit confused about how many controllers I need, and when I can

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.