Operator Overloading
-
Modify CMatrix so that addition is implemented as
operator+().
-
You may simply call the member function Add()
which you have already
defined.
-
Test your implementation with calculations like
- a + b
- a + b + c
- a + a + a + a
-
Also, try to implement operator-() to
handle
a - b - c + d
.
- Hide the messages "Constructor called ..." and "Destructor called ...", because we don't need them now.
- You may test your class with this
main program.
The output may look like
3 3 3 3
3 12 3 3
3 3 101 3
6 6 6 6
6 24 6 6
6 6 202 6
2 2 2 2
2 20 2 2
2 2 2 2
4 4 4 4
4 40 4 4
4 4 4 4