Lab Assignment #5 Solution

$30.00

Description

The class that I am giving you is a revised version of the numbers class that we used in last week’s lab. It stores numbers, and their squares and is called Numbers2. I have come up with a rather unusual way of doing this. Begin by copying all the files from /home/jdolan/cs2401/labs/lab5 to you own working directory.

  1. Open the numbers2.h file and look at the class simple. What does it store? – Explain in as answer one on your answer sheet.

  2. So what is stored in our Numbers2 class? Answer 2 on your answer sheet

  3. Make a drawing of this Numbers2 structure on your answer sheet – in its condition before the resize function is called. (You might understand more if you look at the insert and the display functions, which I have written completely for you.)

  4. The destructor for this class will not be as simple as the one we used in last week’s lab, nor in our project. Explain what needs to be done differently using full English sentences.

  5. The copying process that will be needed for the assignment operator, the resize function and the copy constructor will not be nearly as simple either. Explain, using English sentences, what this copying process will involve.

  6. Looking at the main.cc why do you think that I have the shortlife and longlife objects. Explain whyin English sentences.

Now compile the main.cc and run it with the smaller.dat file

  1. Did it work? What did the output look like?

  2. Try it with larger.dat. Did it work or crash?

Now fix the program by writing a destructor (Include the “I’m melting” message), assignment operator and resize function. You should be able to use what you described in 4) and 5) above.

  1. Now run it again and hopefully it will work with the larger file.

Submit your answer sheet and your completed source code along with output for the larger.dat file.