Author Topic: change a const int?  (Read 1321 times)


  • Guest
change a const int?
« on: January 08, 2013, 07:52:56 pm »
I need to change a const int for a game im making.

right here i make it 1
Code: [Select]

const int MAX_BALLS = 1;

typedef struct
    int ViewHandle;
    float XVelocity;
    float YVelocity;

BallInfo Ball[MAX_BALLS];
int BallWidth;
int BallHeight;
int BallImage;

and then later using ontimer at a certain point i want to change it to 2 so the game will have two balls instead of just one. any idea? THANKS IN ADVANCE!


  • Guest
Re: change a const int?
« Reply #1 on: January 09, 2013, 05:45:07 am »
You cannot change a const int, hence why it is called a constant variable. Once declared, the compiler will assign the value to it in the permanent stack heap (memory) and is therefore not accessible for write operations during the execution of your software. Hope that helps.

You should only use a global variable if you need to modify during different stages of your program although try and avoid using too many globals as this is not good software programming practice


  • Guest
Re: change a const int?
« Reply #2 on: January 09, 2013, 07:07:06 am »
just use regular int insted