Best way to define contants values in a external class


#1

Hi,

I have the following code:

if(Globais::dificuldade==1){
    spiderMoveDuration = 16.0f;
}
if(Globais::dificuldade==2){
    spiderMoveDuration = 8.0f;
}
if(Globais::dificuldade==3){
    spiderMoveDuration = 4.0f;
}

But I want to change the int numbers 1,2,3 to constant values in a external class

I’m new to c**, and I want to define constant values in a external class, how is the best way to do that in c**;


#2

try

#define EASY 1
#define MEDIUM 2

or

enum DIFFICULTY{EASY=1, MEDIUM, HARD};

#3

I try to use

enum DIFFICULTY{EASY=1, MEDIUM, HARD};

But not work for me.

So, I use the

#define EASY 1
#define MEDIUM 2

Works perfect, thank you ‘Alex Zhd’