I\'m wondering why the integer ii
is initiallized at compile time, but not the float ff
here:
int main() {
const int i = 1;
con
In C++ constant integers are treated differently than other constant types. If they are initialized with a compile-time constant expression they can be used in a compile time expression. This was done so that array size could be a const int
instead of #define
d (like you were forced in C):
(Assume no VLA extensions)
const int s = 10;
int a[s]; // OK in C++