In various C code, I see constants defined like this:
#define T 100
Whereas in C++ examples, it is almost always:
const int T =
Due to the differences between the concepts of constant in C and C++, in C we are basically forced to use #define
(or enum
) most of the time. const
just doesn't work in C in most cases.
But in C++ there's no such problem, so it is indeed bad practice to rely on #define
d constants in C++ (unless you really need a textually-substituted constant for some reason).