Carleton
University
Department of Systems and Computer Engineering
SYSC 2002 - Winter 2011
Assignment 8
This assignment involves converting your Customer database class from one that uses a statically allocated array (assignment #7) to one that uses a dynamically allocated array.
The main program provided has been changed to ensure that there is no reference to a full database.
The Customer database class ("CustomerDB.h" and "CustomerDB.cpp") must also change.
- The database can no longer fill up, so make sure there is no reference to a full database anywhere.
- You must now use a dynamically allocated array (instead of a fixed size array):
- Note that while it's not a very efficient choice, to give you experience with dynamic array allocation and deallocation, you must always keep your array the exact length of the current list.
- In other words:
- If the database is empty it is NULL.
- If there is one item in the database, you have a pointer to an array of length 1, etc.
- Unlike with a static array, there is no maximum, i.e. the array can grow as long as needed.
- You need to add three new methods due to the use of a pointer in the fields (see chapter 11).
- Inside your destructor print out a message indicating that you are in the destructor and then pause(). This is so that you can see when the destructor is invoked, even if it is at the end of the program. Every time the message is printed just hit a key to continue.
- You must also write the private methods:
- deleteDB: void with no parameters; this method should be used by 2 public methods
- copyDB: void with one parameter: the database to copy; this method should be used by 2 public methods
The only difference in the behaviour between assignment #7 and assignment #8 is that in #8, the database will never become full, so no new sample exe is needed.
Changes are not required to "Customer.h" and "Customer.cpp" (again, we recommend that you use those provided with the sample solution for assignment #6). Submit files "CustomerDB.h", and "CustomerDB.cpp".
Updated: Mon Feb 28th, 2011