My main code declares a pointer that needs to be resized from an external function. Ex:
double *vect =NULL;
classobj object;
object.func(vect);
//--- print the outcome
for(int j=0; j<4; ++j)
cout << vect[j] << " .. " << endl;
where function func() is part of classobj defined in an another file (say classobj.h and .cpp) as
void classobj::func(double *_vect){
_vect = new double[4];
for(int j=0; j<4; ++j)
_vect[j] = 3.0*j +1 ;
};
The problem is that vect has not been resized. I get segmentation fault. Any idea please on how to use pointers in this case?
void classobj::func(double*& _vect). That said, this is horrible design and is destined to cause even more issues down the line.