Skip to content

Instantly share code, notes, and snippets.

@Ben1980
Created March 5, 2019 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ben1980/b6ca2e79e77e67ffba3d77e633b169eb to your computer and use it in GitHub Desktop.
Save Ben1980/b6ca2e79e77e67ffba3d77e633b169eb to your computer and use it in GitHub Desktop.
struct Vector2D {
double x;
double y;
Vector2D() : x(0), y(0) {}
Vector2D(double x, double y) : x(x), y(y) {}
bool operator==(const Vector2D &rhs) const;
bool operator!=(const Vector2D &rhs) const;
double length() const;
Vector2D& operator-=(const Vector2D& rhs);
Vector2D& operator+=(const Vector2D& rhs);
Vector2D& operator*=(const double& rhs);
Vector2D& operator/=(const double& rhs);
};
Vector2D operator-(const Vector2D &lhs, const Vector2D &rhs);
Vector2D operator+(const Vector2D &lhs, const Vector2D &rhs);
Vector2D operator*(const Vector2D &lhs, const double &rhs);
Vector2D operator*(const double &lhs, const Vector2D &rhs);
Vector2D operator/(const Vector2D &lhs, const double &rhs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment