Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vector {
- public:
- double x_, y_;
- Vector(double x = 0, double y = 0)
- {
- this->x_ = x;
- this->y_ = y;
- }
- void print(int precision = 2, bool newLine = true)
- {
- cout << "(" << setprecision (precision) << fixed << this->x_ << ", " << setprecision (precision) << fixed << this->y_ << ")";
- if (newLine) cout << endl;
- }
- Vector add (const Vector& v) const
- {
- Vector ret;
- ret.x_ = this->x_ + v.x_;
- ret.y_ = this->y_ + v.y_;
- return ret;
- }
- Vector& addTo (const Vector& v)
- {
- this->x_ += v.x_;
- this->y_ += v.y_;
- return *this;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement