Advertisement
_Muhammad

point2d

Feb 18th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1.  
  2. typedef long long ftype;
  3.  
  4. struct point2d {
  5.  
  6. ///We can declear as :
  7. /// point2d a (2, 3, 5);
  8.  
  9. ftype x, y;
  10. point2d() {}
  11.  
  12. point2d(ftype x, ftype y): x(x), y(y) {}
  13.  
  14. point2d& operator+=(const point2d &t) {
  15. x += t.x;
  16. y += t.y;
  17. return *this;
  18. }
  19.  
  20. point2d& operator-=(const point2d &t) {
  21. x -= t.x;
  22. y -= t.y;
  23. return *this;
  24. }
  25.  
  26. point2d& operator*=(ftype t) {
  27. x *= t;
  28. y *= t;
  29. return *this;
  30. }
  31.  
  32. point2d& operator/=(ftype t) {
  33. x /= t;
  34. y /= t;
  35. return *this;
  36. }
  37.  
  38. point2d operator+(const point2d &t) const {
  39. return point2d(*this) += t;
  40. }
  41.  
  42. point2d operator-(const point2d &t) const {
  43. return point2d(*this) -= t;
  44. }
  45.  
  46. point2d operator*(ftype t) const {
  47. return point2d(*this) *= t;
  48. }
  49.  
  50. point2d operator/(ftype t) const {
  51. return point2d(*this) /= t;
  52. }
  53.  
  54. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement