#define myNumber 1
int myNumber 1;
I'm interested to know what the differences are. When I use the first one; In my code I'm treating it as a constant, to avoid magic numbers (http://c2.com/cgi/wiki?MagicNumber). Is that the correct use? Are there any advantages (such as memory usage)?
#define will basically make the compiler do a Search & Replace before the compilation, afaik. Which means the memory used for a #define is essentially 0.
If you tried to actually use that snippet, the second line would turn intoint 1 1; // or: int 1 = 1;
and cause a compilation error.
Cheers for the reply Khris!