Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          const-members/situation-2/prog.cc - A simple client program of Point.Lecture 4 - slide 27 : 40
Program 3

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

using namespace std;

int main(){

  Point p(1,1);

  double pa = p.geta(),    // Activates the caching.
         pr = p.getr();    

  cout << "Point p rectangular: " << p.getx() << ", " << p.gety() << endl;  
  cout << "Point p polar: " << p.getr() << ", " << p.geta() << endl;        
                                                                            
  p.move(2,2);             // Invalidates the cache
  cout << "p moved relatively by (2,2)" << endl;

  cout << "Point p rectangular: " << p.getx() << ", " << p.gety() << endl;  
  cout << "Point p polar: " << p.getr() << ", " << p.geta() << endl;         // Activates the caching.
}