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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:49:28+00:00 2026-05-16T07:49:28+00:00

ok well i have structure struct balls { balls(UINT_PTR const &val) : BALL_ID(val){} int

  • 0

ok well i have structure

struct balls {
    balls(UINT_PTR const &val) : BALL_ID(val){}
    int Ex;
    int Ey;
    const UINT_PTR BALL_ID;
};
balls ball1(0x1);

and i have a switch statement

switch(wParam)
        {
        case ball1.BALL_ID:
                if(ball1.Ex<300)
                {
                    ball1.Ex++;
                }
                else
                {
                    KillTimer(hWnd, ball1.BALL_ID);
                }
                InvalidateRect(hWnd, rect, false);
                break;
        case SCORECOUNTER_ID:
                if(life==0)
                {
                    if(scorecounter<1000)
                    {
                        scorecounter+=100;
                        _swprintf(str, _T("Score: %d"), scorecounter);
                        InvalidateRect(hWnd, rect, false);
                    }
                    else
                    {
                        _swprintf(level, _T("Level: %d"), 2);
                        InvalidateRect(hWnd, rect, false);
                    }
                }
            break;
        }

i get an error thatball1.BALL_ID is not constant the second line should solved this but it didn’t any idea?

  • 1 1 Answer
  • 1 View
  • 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-16T07:49:29+00:00Added an answer on May 16, 2026 at 7:49 am

    The case labels must be integral constant expressions — they must be evaluable during translation (i.e. at compile). In this case, BALL_ID cannot be evaluated at compile-time. Different ball objects are allowed to have different BALL_ID values, hence the compiler cannot possibly evaluate it during translation. Futher, the . (member resolution operator for objects) cannot be used in a case label (i.e. even if you did make BALL_ID static it wouldn’t work for you).

    I would hazard a guess that SCORECOUNTER_ID is a macro/static const int and is hence evaluable by the compiler.

    You can use a namespace scope enum or int to fix this. E.g:

    struct s {
     s(const int t) : x(t) {}
     const int x;
    };
    
    namespace s2 {
     const int val = 42;
    }
    
    int main() {
     s ss(4);
     int val = 42;
     switch (val) {
      case s2::val:
      break;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a structure defined like so: typedef struct { int n; int *n_p;
Suppose I have my node structure as: struct Employee { int age; int salary;
While implementing a FIFO I have used the following structure: struct Node { T
Let's suppose I have a struct like this: struct my_struct { int a; int
Our application is well structured (well we did our best!) and we have split
well i have this messages table with sample values like these: msg_id recipient_id read
Well I have a videos website and a few of its tables are: tags
Well I have this MySQL stored procedure that I wrote and if I run
I have several input and option elements on my page, each (well almost) have
Well basically I have this script that takes a long time to execute and

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.