Advertisement
Glenpl

Untitled

Aug 25th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  * struct Coord // koordynaty hexa
  2. {
  3.     short x, y;
  4.     Coord() {} // lepiej uzywac konstruktora przypisujacego od razu wartosci
  5.     Coord(short x_, short y_) : x(x_), y(y_) {}
  6.  
  7.     bool operator==(const Coord &other) const
  8.     {
  9.         return (x == other.x && y == other.y);
  10.     }
  11.     Coord operator+(const Coord &other) const
  12.     {
  13.         return Coord(x + other.x, y + other.y);
  14.     }
  15.     Coord& operator+=(const Coord &other)
  16.     {
  17.         x += other.x;
  18.         y += other.y;
  19.         return *this;
  20.     }
  21.     Coord operator-(const Coord &other) const
  22.     {
  23.         return Coord(x - other.x, y - other.y);
  24.     }
  25.     Coord& operator-=(const Coord &other)
  26.     {
  27.         x -= other.x;
  28.         y -= other.y;
  29.         return *this;
  30.     }
  31. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement