Assignment #2: More C++ Classes, Separate Compilation and Operator Overloading

Implement a String class with lazy copy semantics. The basic idea is to define a nested StringObject struct:
    struct StringObject
    {
        char *buffer;
        int strLength;
        int bufferLength;
        int referenceCount;   // The number of String that share this.
    };
The String class stores a pointer to StringObject. A copy constructor can then simply copy the pointers, and add one to the referenceCount. The destructor will decrement the referenceCount, and if it falls to zero, reclaim the StringObject (so StringObject should have a destructor). Clearly, the accessors are easily implemented by following the pointer. The mutators require that you make a deep copy of the StringObject (if it is being shared) since at that point, the StringObject can no longer be shared. In that case you will also need to adjust the referenceCount for the pre-existing StringObject. A special case is operator=, which can replace its existing StringObject with a different existing StringObject, adjusting reference counts.