Hi,
I'm trying to make a const function returning a float[3] array with the position of my camera.
But I can't manage to do this, without passing the array as a function parameter.
To be exact, this is what I do now:
void CD3dcam::GetPositionF(float pPos[]) const
{
pPos[0] = mPosition.x;
pPos[1] = mPosition.y;
pPos[2] = mPosition.z;
}
But this is ofcourse annoying if I want to pass GetPositionF to a function as a parameter, where a float array is expected.
So I tried something like
float* CD3dcam::GetPositionF() const
{
float pos[3];
pos[0] = mPosition.x;
pos[1] = mPosition.y;
pos[2] = mPosition.z;
return pos;
}
This compiles, but gives a warning that I'm returning the address of a local variable in memory, instead of a pointer to the actual values.
Any ideas anyone?