I\'ve been looking into this for a few hours, to no avail. Basically I have
struct rectangle {
int x, y, w, h;
};
rectangle player::RegionCoordinates() // R
Since IsCollision
takes a rectangle *
and you are taking the address of the result here:
if (IsCollision(&player1.RegionCoordinates(), &stick1.RegionCoordinates()))
You most likely are returning a rectangle
back from RegionCoordinates()
which is a temporary variable since it will disappear after the if
statement is done. If you assign the result of RegionCoordinates()
to a variable then it will no longer be a temporary and you can then take the address of it:
rectangle r1 = player1.RegionCoordinates() ;
rectangle r2 = stick1.RegionCoordinates() ;
if (IsCollision(&r1, &r2))
Alternatively you could take the parameters as const
references which would be the more C++ way of doing it:
bool IsCollision (const rectangle &r1, const rectangle &r2)