CJCoding With Joseph
15free / daySign inCreate account

Rectangle Combine Dimensions (operator+)

You are combining two rectangular boards end-to-end.

Create a class Rectangle with private ints width and height.

Requirements:
1) Constructor Rectangle(int w, int h)
2) Getters getW() const, getH() const
3) Overload operator+ to return a NEW Rectangle whose width is (w1 + w2) and height is (h1 + h2)

Do NOT write a main function.

Expected Output:

7x5
5x9

= newline. The output ends with a newline — print one after the last line.

Hints2 available
Topics:
ClassesOperator Overloading
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.