Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          constructors-initialization-assignment/rect-ass.cc - Rectangle constructors - with default initialization and subsequent assignments - BAD STYLE.Lecture 4 - slide 5 : 40
Program 5

// Alternative definitions of Rectangle constructors. BAD STYLE. 

#include <cmath>
#include <iostream>
#include "rect.h"

Rectangle::Rectangle(){
  upper_left = Point(-1,1);        // Assignments done after default initialization
  lower_right = Point(1,-1);       // Too expensive. Bad style in C++.
}

Rectangle::Rectangle(double x1, double y1, double x2, double y2){
  upper_left = Point(x1,y1);
  lower_right = Point(x2,y2);
}

Rectangle::Rectangle(Point p1, Point p2){
  upper_left = p1;
  lower_right = p2;
}