Hi,
I have the following functions
void LoadData(char* file, float* data1, float* data2)
{
// read data size and contents from file
data1 = new float[dataSize1];
data2 = new float[dataSize2];
// store data
data1[0] = 1.0f;
data1[1] = 2.0f;
// etc ...
}
void ComputeData()
{
float *data1 = NULL;
float *data2 = NULL;
LoadData("file.txt", data1, data2);
// on this line, data1 and data2 is still NULL;
}
Why doesn't the data pointers from ComputeData() point to the memory location?
How do I go about implementing LoadData() to output the arrays in the parameters?
EDIT:
Ok i found that if I modify the LoadData to
void LoadData(char* file, float*& data1, float*& data2)
Then it will work... this is the first time I'm seeing and using this. I never knew they need to be references. Any comments on efficiency or safety?