fork download
  1. class Vector2D
  2. {
  3. private:
  4. int m_x, m_y;
  5. public:
  6.  
  7. Vector2D(int x, int y);
  8. int getX() const;
  9. int getY() const;
  10. void setX(int x);
  11. void setY(int y);
  12. Vector2D& operator+=(Vector2D const&);
  13. };
  14.  
  15. Vector2D::Vector2D(int x, int y)
  16. {
  17. m_x = x;
  18. m_y = y;
  19. }
  20.  
  21. int Vector2D::getX() const
  22. {
  23. return m_x;
  24. }
  25.  
  26. int Vector2D::getY() const
  27. {
  28. return m_y;
  29. }
  30.  
  31. void Vector2D::setX(int x)
  32. {
  33. m_x = x;
  34. }
  35.  
  36. void Vector2D::setY(int y)
  37. {
  38. m_y = y;
  39. }
  40.  
  41. Vector2D& Vector2D::operator+=(Vector2D const& toAdd)
  42. {
  43. m_x += toAdd.getX();
  44. m_y += toAdd.getY();
  45. return *this;
  46. }
  47.  
  48. int main()
  49. {
  50. return 0;
  51. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty