this is a homework task im completly lost in?
we need to implement this header file below
i like to think im pretty good at arrays and classes.... but the new additon of dynamic arrays has got me really confused... any help would be greatly appreciated
#include <iostream>
using namespace std;
class Collector {
public:
// make a collector for things
Collector(); /// The constructor should allocate (with operator new) the initial array of strings
~Collector(); // Make sure that the destructor cleans up all of the storage allocated by this object
Collector(Collector &other); // Copy constructor should perform a deep copy of other
// collect a thing of type string
// the string is added to the array of things
// you MUST make use of the 'next' private member
// you should check there is available space in the array to add this new string
// use grow() if there is not enough space
void collect(string name);
// return the current size of the collection (NOT the maximum size of the collection)
int size();
// get element i of the collection
// checks that i is in bounds of the non null portion of the collection and returns "" if not
string get(int i);
// print all non null elements of the collection with a space between each element
void print();
protected: // local helper functions go here
void grow();
// grow the collection by INITSIZE eg. current max size is 20, this function should grow it to 30
// - called if the things array doesn't have room for any extra things
private:
static const int INITSIZE = 10; // initial size of the array and amount we grow by each time
string *things; // pointer to our array of things
int arraysize; // current maximum size of the array
int next; // location of the next free (available) element in the array
};