Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          point-cpp-cs-exercise/cpp/prog1.cc - The C++ client program with pointers - free store allocation.Lecture 2 - slide 27 : 27
Program 6

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

using namespace std;

Point *pointmover(Point *pa, Point *pb){
  pa->move(5,6);
  pb->move(-5,-6);
  return pb;
}

void go(){
  Point *p1 = new Point(1, 2),
        *p2 = new Point(3, 4),
        *p3 = p1,
        *p4 = p2,
        *p5;

    p5 = pointmover(p1, p2);

    cout << *p1 << endl <<    // (6,8)
            *p2 << endl <<    // (-2,-2)
            *p3 << endl <<    // (6,8)
            *p4 << endl <<    // (-2,-2)
            *p5 << endl;      // (-2,-2)

  delete p1;
  delete p2;
}

int main(){
  go();
}