The short answer is that you cannot return an array. You can return a pointer to dynamically allocated memory:
int* moves = target_function();
delete[] moves;
To allocate memory, <<21> must use new.
Note that this is not ideal in terms of memory management, because it is easy to forget to call delete[]in the returned array. Instead, consider returning std::vector<int>.
source
share