Comp 272 Program 5 Fall 2002 Dordal Due: Day of final (Dec 11), or within a day or so. For your last program, you are to build a simple string class, to be called "string2". This class should contain a copy ctor, ctors from (the existing class) string and (native C strings) char*, a destructor (dtor), ie string2(string2 &) string2(string) string2(char*) ~string2() and support for the following operations (all within the class string2 except for operator<<, to be defined outside): operator= operator== operator[] operator<<(ostream&, string2&) operator+=(string2 &) // append a string operator+=(char) // append a char Basically you are to follow the model of the T_array example, except that because of the desire to support += *without* constant reallocation of memory, you should when creating a string **leave some extra space**. Thus, a string2 object will have the following private data: char* _data; int _currsize; int _maxsize; // amount actually allocated. When a string is first created, you should be sure that _maxsize is bigger than the size needed, say twice _currsize, or equal to _currsize+100, or the next highest power of 2. This allows some room for growth, so that adding one character doesn't always force reallocation. This is the only real difference between string2 and T_array (with T changed to "char"). A native C array of characters is type char[], identical to char* on the theory that an array is really a pointer to an array, and a pointer to a character is identified with a pointer to the start of an array (string) of characters. Thus, if you allocate space for 100 characters: _data = new char[100]; then you can access the ith character (starting at 0) as _data[i]. Native C strings assume one more thing: that the first byte *after* the end of the string is a 0 byte, to mark the end. With this 0 byte in place you can use the functions int strlen(char*) and strcpy() to find the length of a string and copy it. Or, you can just skip that and just handle the bytes directly. Demonstrate your program on some simple examples, showing += cases that both do and do not force reallocation. Be sure to test the ctors too.