Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          constructors/move/prog.cc - Use of constructors - with local variables of class type.Lecture 4 - slide 10 : 40
Program 3

//Point(): (0,7)                    Point(double x): (x, 20)           Point(double x, double y): (x, y)     
//Point(Point& p) (p.x+1, p.y+2)    Point(Point&& p) (p.x-3, p.y-4) 
//Reveal...

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

using namespace std;

//A Point identity function - revealing the parameter p by printing on standard output.
Point pf(Point p){
  cout << "Inside pf: Parameter: " << p << endl;
  return p;
}

int f(){
  Point p;
  cout << "Point p: " << p << endl;   // (0,7)


  Point q = pf(p);                    // Passing p to pf via copy constructor: (1,9)
  cout << "Point q: " << q << endl;   // (-2,5) -  because pf handles return via the move constructor. 


  Point r = pf(Point{10,12});         // Constructing point (10,12) via Point(double,double). Passing it bitwise!?
  cout << "Point r: " << r << endl;   // (7,8).  Returning via use of move constructor. 


  Point s = pf(move(Point{10,12}));   // Passing Rvalue point (10, 12) to pf via forced used of move constructor (7,8). 
  cout << "Point s: " << s << endl;   // (4,4) -  because pf handles return via the move constructor. 
}

int main(){
  f();
}