I made a small code to resize a dynamic array, passing pointer X as a reference.
void resize(int*& X , int & dimX){
int * new_X = new int [dimX+20];
for(int i=0;i<dimX;i++)
new_X[i] = X[i];
delete [] X;
X = new_X;
dimX += 20;
}
My doubt is: what would be the difference in the code if i decided to pass the array X as a sole pointer? For example:
void resize(int* X , int & dimX)
Is that even possible for this kind of operation? (resizing). Thanks a lot and sorry for the dumb question, i'm a beginner.
std::vectororstd::listif you need a "dynamic" collection.