Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          pointer-to-member/point.cc - Implementation of class Point and the tree move methods - not important for the example.Lecture 5 - slide 14 : 40
Program 2

// Implementation of the member functions. Not really important for the example.

#include <cmath>
#include <iostream>
#include "point.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;
}

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

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

void Point::move_absolute(double x1, double y1){
    x = x1; y = y1;
}

void Point::move_funny(double dx, double dy){
    x += dx*2; y -= dy;
}

double Point::distance_to(Point p){
    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() << ")" ;
}