Why am I able to use a locally declared const int as the size of an array declaration but am not allowed to do the same with a const int passed as
In f2 the constant dim is known at compile time, in f1 it's not.
And since C++ doesn't have variable-length arrays the dimensions of an array must be known at compile time.
The use of const for function arguments is more of a hint to the compiler that the function will not modify the argument, allowing the compiler to for example make optimizations based on that information.