CIS 22B - Notes for Tuesday, 11/10

Announcements and Reminders

Recording

Examples Presented in class
Constructor Initializers
Clard And Deck classes - rewrite #1
Clard And Deck classes - rewrite #2
The Person class with a copy constructor

More Constructors and Destructors

Remember this

C++ Initializers / initialization list

C++ 11 initialization changes


Lab Exercise #8

Put your name, the compiler and operating system used, and Lab Exercise #7 in a comment at the top of your program. Email your source code.

Complete the follwoing program using the incomplete Rectangle class.  Write 3 constructors and a destructor to satisfy the main() below.  Use constructor initializers for each constructor.  Add print statements in the constructors and destructor to produce the output shown below.

class Rectangle
{
   float* length;
   float* width;
...
???
...
};

...

int main()
{
    Rectangle r1;
    Rectangle r2(4.5,2.3);
    Rectangle r3(r2);
    cout << r1.area() << endl;
    cout << r2.area() << endl;
    cout << r3.area() << endl;
}


******  Program Output  ******

default constructor called
second constructor called
copy constructor called
0
10.35
10.35
destructor called
destructor called
destructor called