| Method: |
Using the Bag class gone over in class:
- add two constructors; one that will be the default constructor that will always instantiate
the bag with room for 10 items, and a second constructor that will take an integer (i) input
and will instantiate the bag with room for i items. Remember that the insert and
remove methods can affect the size of the array in that if insert causes the array to fill
up then it should insure that it never fills up (by increasing the size of the dynamic
array); likewise after a remove check if the dynamic array is less than half full then
reallocate it as half the current size.
- add a copy constructor to the class
- add an overloaded assignment (=) operator to the class
- add an overloaded plus (+) operator that will allow the contents of one bag to be added to another bag
( this should leave one bag empty and the other bag with all of the items).
- add a destructor to the class that will return any dynamically allocated storage
to the C++ run-time storage management system.
- compile Bag.cpp and get rid of any editing induced errors
- create a new file called main1.cpp and write a short test program that tests the two
constructors and the modified insert and remove methods (print out proof that they work).
- compile main1.cpp, get rid of any compile errors and run
- create a new file called main2.cpp and write a short test program that tests the
the copy constructor (print out evidence (on the console) that the copy constructor works properly).
- compile main2.cpp, get rid of any compile errors and run
- create a new file called main3.cpp and write a short test program that tests the
overloaded assignment (=) operator (print out evidence (on the console) that the overloaded = works.
- compile main3.cpp, get rid of any compile errors and run.
- create a new file called main4.cpp and write a short test program that tests the
overloaded plus (+) operator( print out evidence (on the console) that the overloaded + works.
- compile main4.cpp, get rid of any compile errors and run.
- create a new file called main5.cpp and write a short test program that tests the
the class destructor (print out evidence (on the console) that the copy constructor works properly).
- compile main5.cpp, get rid of any compile errors and run
|