1/* { dg-do compile } */ 2 3struct VectorD2 4{ 5 VectorD2() : x(0), y(0) { } 6 VectorD2(int _x, int _y) : x(_x), y(_y) { } 7 int x, y; 8 int GetLength2() const { return x*x + y*y; }; 9 VectorD2 operator+(const VectorD2 vec) const { 10 return VectorD2(x+vec.x,y+vec.y); 11 } 12}; 13struct Shape 14{ 15 enum Type { ST_RECT, ST_CIRCLE } type; 16 VectorD2 pos; 17 VectorD2 radius; 18 bool CollisionWith(const Shape& s) const; 19}; 20bool Shape::CollisionWith(const Shape& s) const 21{ 22 if(type == ST_CIRCLE && s.type == ST_RECT) 23 return s.CollisionWith(*this); 24 return (pos + s.pos).GetLength2() < (radius + s.radius).GetLength2(); 25} 26