Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'                classes/point5/point5.cc - Definition of function members.Lecture 4 - slide 2 : 40
Program 6

// Using in-class initialized data member is several constructors.

#include <cmath>
#include <iostream>
#include "point5.h"

Point::Point(double x_coord, double y_coord): x{x_coord}, y{y_coord}{
}

Point::Point(): x{0.0}, y{0.0}{
}

double Point::getx () const{
  return x * scaling_factor;
}

double Point::gety () const{
  return y * scaling_factor;;
}

void Point::move(double dx, double dy){
    x += dx; y += dy;
}

double Point::distance_to(Point p) const{
    return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));
}

std::ostream& operator<<(std::ostream& s, const Point& p){
  return s << "(" << p.getx() << "," << p.gety() << ")";
}