Consider these functions:
void OperateOnDoublePointer(double* a)
{
std::cout << a[0] << std::endl;
}
void OperateOnFloatPointer(float* a)
{
std::cout << a[0] << std::endl;
}
This works as expected:
double* c = new double[1];
c[0] = 3.3;
OperateOnDoublePointer(c);
but when I try to do this:
double* c = new double[1];
c[0] = 3.3;
OperateOnFloatPointer(c);
It complains that it can't convert double* to float*.
I tried to tell it that was ok:
OperateOnFloatPointer(static_cast<float*>(c));
but it said can't cast double* to float*.
If I do this, it works:
float* d = new float[1];
d[0] = c[0];
OperateOnFloatPointer(d);
but I'd have to loop over all elements. Is there a single line way to do this (pass a float* to a function expecting a double*, or visc versa)?
Thanks,
Dave