#include <iostream>

#include <cmath>

#include <cstdlib>



using namespace std;



class Point {

 public:

  Point(const int x, const int y);     // constructor

  Point(const Point& copyme);          // copy constructor

  Point &operator=(const Point &rhs);  // assignment operator

  ~Point();                            // destructor



  int get_x() const { return x_; }  // inline member function

  int get_y() const { return y_; }  // inline member function



  double Distance(const Point &p) const;

  void SetLocation(const int x, const int y);



 private:

  int x_;  // data member

  int y_;  // data member

};  // class Point



Point::Point(const int x, const int y) : x_(x), y_(y) {

  cout << "Point constructor called" << endl;

}



Point::Point(const Point& copyme) {

  cout << "Point copy constructor called" << endl;

  x_ = copyme.x_;

  y_ = copyme.y_;

}



Point& Point::operator=(const Point& rhs) {

  cout << "Point assignment operator called" << endl;

  if (this != &rhs) {

    x_ = rhs.x_;

    y_ = rhs.y_;

  }

  return *this;

}



Point::~Point() {

  cout << "Point destructor called" << endl;

}



double Point::Distance(const Point &p) const {

  double distance = (x_ - p.x_) * (x_ - p.x_);

  distance += (y_ - p.y_) * (y_ - p.y_);

  return sqrt(distance);

}



void Point::SetLocation(const int x, const int y) {

  x_ = x;

  y_ = y;

}



Point PrintRad(Point& pt) {  // non-member function

  Point origin(0, 0);

  double r = origin.Distance(pt);

  double theta = atan2(pt.get_y(), pt.get_x());

  cout << "r = " << r << endl;

  cout << "theta = " << theta << " rad" << endl;

  return pt;

}



int main(int argc, char** argv) {

  Point pt(3, 4);

  PrintRad(pt);

  return EXIT_SUCCESS;

}