I've been reading that arrays should have a size known at a compile time. Here is an example piece of code:
int temp = 5;
const int size = temp;
int array[size];
According to the author, the size is known at runtime and results in an error.
However, I compiled and ran the code and there was no error.
Is the author right that in the above piece of code the size of the array is known at runtime? If he is, why was I able to compile and run the code?
In my opinion the size is known at compile-time. Is there something that I don't understand?
Edit. I used the g++ compiler and no extra options: g++ main.C -o main