#include using namespace std; const int vals[] = {0, 1, 2, 3, 4}; int newArray[ vals[2] ]; //\"error: array bound is not an integer constant\"
The C++ compiler can only allocate an array with a size known at compile time. If you want to allocated a variable size piece of memory, use the new operator.
new