123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #include "Point.h"
- //METHODS
- //constructor
- Point::Point(double x, double y)
- {
- m_x = x;
- m_y = y;
- }
- //destructor
- Point::~Point()
- {
- //???
- }
- //Get_all
- void Point::Get_all(double& x, double& y)
- {
- x = m_x;
- y = m_y;
- }
- //Get_all const
- void Point::Get_all(double& x, double& y) const
- {
- x = m_x;
- y = m_y;
- }
- //Set_all
- void Point::Set_all(double& x, double& y)
- {
- m_x = x;
- m_y = y;
- }
- //operator=
- Point& Point::operator=(const Point& other)
- {
- m_x = other.m_x;
- m_y = other.m_y;
- return *this;
- }
- //operator=
- Point& Point::operator=(Point&& other)
- {
- m_x = other.m_x;
- m_y = other.m_y;
- return *this;
- }
- //operator+
- Point Point::operator+(const Point& other) const
- {
- return Point(m_x + other.m_x, m_y + other.m_y);
- }
- //operator+
- Point Point::operator+(const double num) const
- {
- return Point(m_x + num, m_y + num);
- }
- //operator+=
- Point& Point::operator+=(const Point& other)
- {
- m_x += other.m_x;
- m_y += other.m_y;
- return *this;
- }
- //operator+=
- Point& Point::operator+=(const double num)
- {
- m_x += num;
- m_y += num;
- return *this;
- }
- //Point& Point::operator+=(Point&& other)
- //{
- // m_x += other.m_x;
- // m_y += other.m_y;
- // return *this;
- //}
- //operator+ uno
- Point Point::operator+() const
- {
- return Point(+m_x,+m_y);
- }
- //operator- uno
- Point Point::operator-() const
- {
- return Point(-m_x, -m_y);
- }
- //GLOBAL FUNCTIONS
- //operator+
- Point operator+(const double num, const Point& other)
- {
- double Other_x, Other_y;
- other.Get_all(Other_x, Other_y);
- return Point(Other_x + num, Other_y + num);
- }
- //operator-
- Point operator-(const Point& thirst, const double num)
- {
- double thirst_x, thirst_y;
- thirst.Get_all(thirst_x, thirst_y);
- return Point(thirst_x - num, thirst_y - num);
- }
- //operator-
- Point operator-(const Point& thirst, const Point& second)
- {
- double thirst_x, thirst_y, second_x, second_y;
- thirst.Get_all(thirst_x, thirst_y);
- second.Get_all(second_x, second_y);
- return Point(thirst_x - second_x, thirst_y - second_y);
- }
- //operator-=
- Point& operator-=(Point& This, const Point& Other)
- {
- double This_x, This_y, Other_x, Other_y;
- This.Get_all(This_x, This_y);
- Other.Get_all(Other_x, Other_y);
- This.Set_all(This_x -= Other_x, This_y -= Other_y);
- return This;
- }
|