I would like to understand the difference between defining a constant variable as follows:
const int ONE = 1;
and using a preprocessor directive:
#define ONE (1)
I know that in the second case "1" gets in some sense hardcoded and the compiler does not even see the variable ONE, but I am not sure about the first case. The fact of declaring the variable as constant just prevents from accidentally change its value, or does the compiler catch the opportunity to do some optimization? Is there any significant benefit of one approach over the other?