Challenge: Define a Class that Performs Operations on a String

Write code as a class that performs operations on a string.

Implement a String class that contains the following functions:

  • A constructor to store the string.

  • An overloaded += operator function to perform string concatenation.

  • The toLower() method to convert uppercase letters to lowercase.

  • The toUpper() method to convert lowercase letters to uppercase.

  • The getString() method to return the stored string.


  • Input: We use the string as input.

  • Output: We get the stored string from the class, convert the uppercase string to lowercase, the lowercase string to uppercase, and concatenate two strings.

Get hands-on with 1200+ tech skills courses.