So an enum works like this:
enum {
false,
true
}
which is equivalent to
int false = 0
int true = 1
Why wouldn't I substitute enum
with #define
?
#define FALSE 0
#define TRUE 1
To me, it seems like they are interchangeable. I'm aware that #define
is able to handle arguments, hence operates in an entirely different way than enum
. What exactly are the main uses of enum
when we have #define
in this case?
If I were to guess, as the #define
is a preprocessor feature, enum
would have some runtime advantages. How far off am I?
Thanks in advance.