Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          destructors/point.cc - Implementation of the destructor that reveal its activation.Lecture 4 - slide 11 : 40
Program 2

// A 'revealing implementation' of the destructor.

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


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

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

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

Point::Point(const Point& p): x(p.x + 1.0), y(p.y + 2.0){
}

Point::~Point(){
  std::cout << "Deleting point" << "(" << x << "," << y << ")" << std::endl;
  // No real work for the constructor in this version of class Point.
}


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

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

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