Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          constructors/prog2-more.cc - An additional Point construction attempt - a trap.Lecture 4 - slide 8 : 40
Program 5

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

using namespace std;

int f(){

  Point p, q,                         // The default constructor is used for both p and q  
        q1(),                         // Most likely an error. 
                                      // What is it? A declaration of a parameterless point returning function.
        r(11.0, 12.0),                // Point(double,double) used
        s(p),                         // The copy constructor used
        t(3.0),                       // Point(double) used
        u = t,                        // Another way to use the copy constructor, via an initializer
        ap[10];                       // The default constructor used 10 times

  q = r;                              // default assignment - bit-wise copying, no use of copy constructor

  cout << "Point p: " << p << endl;   // (0,7)
  cout << "Point q: " << q << endl;   // (11,12)  - because of the assignment q = r
  cout << "Point q1: " << q1 << endl; // ?????
  cout << "Point r: " << r << endl;   // (11,12)
  cout << "Point s: " << s << endl;   // (1,9)
  cout << "Point t: " << t << endl;   // (3,20)
  cout << "Point u: " << u << endl;   // (4,22)

  for(int i = 0; i < 10; i++)         // (0,7) ten times
     cout << "ap[" << i << 
     "]: " << ap[i] << endl;  

}

int main(){
  f();
}