BecauseIn C++, the length of an array needs to be known at compile time, in order to allocate the arrayit on the stack, the compiler needs to know the size of the array during compiletime.
WhatIf you wantneed to allocate an array whose size you do instead is:not know at compile time, you'll need to allocate it on the heap, using operator new[]
int size = menu.size;
int *list = new int[size];
But since you've new'd memory on the heap, you need to ensure you properly delete it when you are done with it.
delete[] list;