CJCoding With Joseph
15per day

TextLabel Concatenation (operator+ and operator+=)

You are building UI labels that have a prefix and main text.

Create a class TextLabel that stores TWO strings: prefix and text.

Rules:
- getText() should return prefix + text
- When combining labels, you should combine BOTH parts.

Requirements:
1) Constructor TextLabel(string prefix, string text)
2) string getText() const
3) operator+= appends other.prefix to this->prefix AND other.text to this->text
4) operator+ returns a NEW TextLabel using operator+=

Do NOT write a main function.

Expected Output:

HelloWorld
CWJ Rocks
Topics:
ClassesOperator Overloading
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.