Why can\'t I do something like this:
int size = menu.size;
int list[size];
Is there anyway around this instead of using a vector? (arrays a
C++ does not allow variable length arrays. The size must be known at compile-time. So you can't do that.
You can either use vectors or new
.
vector list;
or
int *list = new int[size];
If you go with the latter, you need to free it later on:
delete[] list;
arrays are faster, so I wanted to use arrays
This is not true. Where did you hear this from?