Write a MyString class that stores a (null-terminated) char* and a length and implements all of the member functions below. Submit your completed source (.cpp) file.
- Default constructor: empty string
- const char* constructor: initializes data members appropriately
- Copy constructor: prints “Copy constructor” and endl in addition to making a copy
- Move constructor: prints “Move constructor” and endl in addition to moving data
- Copy assignment operator: prints “Copy assignment” and endl in addition to making a copy
- Move assignment operator: prints “Move assignment” and endl in addition to moving data
- Destructor
- Array index overload (e.g., str[2]): should be able to read or write the character in this position. Don’t test for out-of-bounds indices.
- Concatenation (+) operator: returns the concatenation of this string with the other. Does not modify either object.
- Print function that works with cout
0 comments