Is there any difference between these two declarations?
int x[10];
vs.
int* x = new int[10];
I suppose th
If you want to size an array dynamically, e.g.:
void doSomething(int size)
{
int x[size]; // does not compile
int *z = new int[size];
//Do something interesting ...
doMore(z, size);
}
then x will not compile in C++, so you have to use z. The good news is that you can now use z, in most cases, as though it were statically allocated, e.g.:
void doMore(int anArray[], int size)
{
// ...
}
takes z as an argument, treating the pointer as an array.