I am confused. I can not use this on a float? must it be a interger ?? I try to define that as a point but I guess I can not convert float to float *
//global definition
float g_posX = 0.0f;
&g_posX -= 3.03f;
I am confused. I can not use this on a float? must it be a interger ?? I try to define that as a point but I guess I can not convert float to float *
//global definition
float g_posX = 0.0f;
&g_posX -= 3.03f;
If you want to subtract from the float then just name the variable and don't take its address:
g_posX -= 3.03f;
Otherwise, &g_posX
is an rvalue
that you can't assign to it anything.
You probably simply want to do this:
float g_posX = 0.0f;
g_posX -= 3.03f;
What your code tries to do is take the address of g_posX
and subtract 3.03f
from the address. That does not work, for two reasons:
well, &g_posX
is a pointer to the float. Pointers are memory addresses and (more or less) intereger. To increase the float, simply remove the &
.
You don't need the the & before g_posX, just do the maths like
g_posX -= 3.03f;
increment and decrement operators are only defined for integral data types, not for floating point, double, etc.