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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:31:11+00:00 2026-05-18T22:31:11+00:00

Coming from a C# background from a night course at a local college, I’ve

  • 0

Coming from a C# background from a night course at a local college, I’ve sort of started my way in C++. Having a lot pain getting used to the syntax. I’m also still very green when it comes to coding techniques.

From my WinMain function, I want to be able to access a variable which is using an enum I declared in another class.

(inside core.h)
class Core
{
    public:
    enum GAME_MODE
    {
        INIT,
        MENUS,
        GAMEPLAY
    };
    GAME_MODE gameMode;

    Core();
    ~Core();
    ...OtherFunctions();
};

(inside main.cpp)
Core core;
int WINAPI WinMain(...)
{
    ... startup code here...

    core.gameMode = Core.GAME_MODE.INIT;

    ...etc...
}

Basically I want to set that gameMode to the enum value of Init or something like that from my WinMain function. I want to also be able to read it from other areas.

I get the error…

expected primary-expression before '.' token

If I try to use core.gameMode = Core::GAME_MODE.INIT;, then I get the same error.

I’m not fussed about best practices, as I’m just trying to get the basic understanding of passing around variables in C++ between files. I’ll be making sure variables are protected and neatly tucked away later on once I am use to the flexibility of the syntax.

If I remember correctly, C# allowed me to use Enums from other classes, and all I had to do was something like Core.ENUMNAME.ENUMVALUE.

I hope what I’m wanting to do is clear :\ As I have no idea what a lot of the correct terminology is.

  • 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-18T22:31:12+00:00Added an answer on May 18, 2026 at 10:31 pm

    Use

    core.gameMode = Core::INIT;
    

    The individual values of an enumeration are scoped not within that enumeration but at the same level as the enumeration itself. This is something that most other languages (including C#) do differently, and C++0x will allow both variants so that there,

    core.gameMode = Core::GAME_MODE::INIT;
    

    will also be legal.

    In addition, the strongly typed enums that will be added in C++0x (enum class) will put the enum values only within the scope of the enum (i.e. as in C#); this solves the problem you noted in your comment that for “normal” enums, the identifiers for enum values need to be unique across all enums defined in the same scope.

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

Sidebar

Related Questions

Coming from .NET background ... Is there a way to either via key stroke
I just started using LISP, coming from a background in C. So far its
I'm studying C++ right now, coming from a background in Python, and I'm having
Coming from a background, I'm familiar with GUI editors that do a poor job
Coming from a background in Django, I often use template inheritance, where multiple templates
I'm coming from a background in ColdFusion, and finally moving onto something modern, so
When I was learning Java coming from a background of some 20 years of
Coming from a C# background the naming convention for variables and methods are usually
Coming from a desktop background I'm not sure exactly how to pass the exceptions
Coming from a java background, one of the things I am used to is

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.