Is there any difference between these two declarations?
int x[10];
vs.
int* x = new int[10];
I suppose th
First case: x
is created on stack/data segment based on whether it's non-static local variable or static/global variable. And address of x
is not modifiable.
Second case: 'x' is a pointer pointing to an array created generally on heap (free store). You can change x
pointing to something else also. Moreover, you need to take care of deallocating it by using delete[] x;