String Class in C++
Write your own String class to mimic some functionality from the str class in Java. As much as possible, functionality of your methods should match the functionality provided by the String class in Java, so visit the Java API for more details on what those methods should do.
You may use the C++ std::string type as your instance variable, and use any methods provided by
Notes of interest:
• Overloaded operators, e.g., operator==, are covered in a number of places on the web, include https://
isocpp.org/wiki/faq/operator-overloading. Find one that works well for you.
• A reasonable API reference for the C++ libraries can be found at http://www.cplusplus.com/.
• Appropriate use of the C++ std::string methods will result in brief implementations for many of the methods.
• For handling invalid indices to substring, you should throw an out-of-range exception defined in
This will require a try-catch block in your tester — see std::exception at the C++ API for help. • Make sure to handle the case of a nullptr being passed as the C-string literal to your corresponding constructor — throw an invalid-argument exception. • In your submission, include a README.txt file describing your tests (don’t forget boundary/edge cases), their results, and how they demonstrate the correctness of your implementation. • Follow style guidelines — include a class block comment with name, date, and that describes the class; include comments before each method; use inline comments as appropriate; make judicious use of whitespace, good naming convention, consistent indentation, etc.