I have to make a overloading operator- in my program, I know how to make a overloading operator++ and -- but I don't know how to make + and -. Can someone help me?
I stored 3 members in 2 classes and I want to subtract them in the operator-.
I found that I cannot subtract the members by using box1.length - box2.length.
What can I do to subtract the members?
For example:
box1
length = 10
wide = 20
height = 30
box2
length = 30
wide = 20
height = 10
Then I write this
1 2 3 4 5 6 7 8 9 10
class Date
{
private:
int length, height, wide;
Box& Box::operator-()
{
length = box1.length - box2.length; //Compiler error there
wide = box1.wide - box2.wide; //Same error
height = box1.height - box2.height; //Same error
}