Pretty good, but a few issues.
1.
1 2 3
|
int SetitsHeight(int height) {itsHeight = height;}
int SetitsLength(int length){itsLength= length;}
int SetitsWidth(int width){itsWidth = width;}
|
None of these functions return a value. Make them
void instead of
int.
2.
5
3 = 125. Good.
7
3 = 343. Good.
You're last number is 1728. This is 12
3. That is the correct behavior as you have your program now.
Of course it doesn't equal 125 + 343 = 468, because you're adding lengths, not volumes.
(2 + 3)
3 does not equal 2
3 + 3
3.
The end result of your addition is doing (5+7)*(5+7)*(5+7) for height * width * length. Not to mention, a 468-volume cube can't have integer side lengths, because 468 isn't a cube number.
The problem with operation overloading is it can be abused. What does it mean to add two Boxes together?
This is a question you need to ask yourself, and provide clear test cases for.
If you want the volumes to be preserved (3 volume + 4 volume = 7 volume), then it's ambiguous as to how a 3*4*5 box should be added to a 2 * 3 * 4 box. The combined volume mathematically should be 60 + 24 = 84, but what should the new length, width, and heights be? It's ambiguous; there could be multiple answers.
You need to think about what adding boxes should actually mean.
If there isn't a way to intuitively use addition, don't operator overload it.