void foo (int k)
{
int C[size(k)][size(k)];
C[1][2] = 4;
std::cout << C[1][2];
}
How this code is compiled correctly?
void foo (int k)
{
int C[size(k)][size(k)];
C[1][2] = 4;
std::cout << C[1][2];
}
How this code is compiled correctly?
You code compiles with g++ because it supports variable length arrays as an extension; see 6.19 Arrays of Variable Length
It's not a feature of standard C++, so it won't necessarily work with other compilers.
If you want g++ to complain about this sort of thing, give it -pedantic
.