if I create a new int array object using new
like below:
int *array = new int[20];
and fill the array with some integers, then attempting to scan through that array with a for-each loop will throw me an error:
for (int x : array) // error
why does this happen and how can I fix it? I tried playing around with the referencer and address notations (*
and &
) but every combination I tried fails.
ex.
for (int &x : *array) // does not work either.