Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          operators/vers1/prog.cc - A program that illustrates uses the Point operators.Lecture 4 - slide 40 : 40
Program 3

// Sample use of Point operators.

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

using namespace std;

int main(){

  Point p(1,2),
        q(3,4),
        r(10,12);

  cout << "Point p: " << p << endl;    // (1,2)
  cout << "Point q: " << q << endl;    // (3,4)
  cout << "Point r: " << r << endl;    // (10,12)

  cout << "Point q and q are" << ((p==q) ? "" : " not") << " equal" << endl;   // equal
  cout << "Point p and r are" << ((p==r) ? "" : " not") << " equal" << endl;   // NOT equal

  p++; q++;
  cout << "After p++: Point p: " << p << endl;  // (2,3)
  cout << "After q++: Point q: " << q << endl;  // (4,5)

  const Point &t = p + q;
  cout << "Point t = p + q: " << t << endl;     // (6,8)
}