Since IsCollision accepts a rectangle * , and you take the address of the result here:
if (IsCollision(&player1.RegionCoordinates(), &stick1.RegionCoordinates()))
You are most likely returning the rectangle back from RegionCoordinates() , which is a temporary variable, since it will disappear after the if executed. If you assign the result of RegionCoordinates() variable, then it will cease to be temporary, and you can take its address:
rectangle r1 = player1.RegionCoordinates() ; rectangle r2 = stick1.RegionCoordinates() ; if (IsCollision(&r1, &r2))
Alternatively, you can take parameters as const links, which will be more similar to C ++:
bool IsCollision (const rectangle &r1, const rectangle &r2)
Shafik yaghmour
source share