I'm trying to overload the - and -= operators for use on a linked list. I need to be able to subtract two linked lists. So if, as an example, I had
Code:
{2,2,2,3,2,2,1} - {2,2,3}
I would get as a result.
So far I have this as a non-member function:
Code:
bag operator -(const bag& b1, const bag& b2)
{
bag answer;
answer -= b1;
answer -= b2;
return answer;
}
However, I am missing the member function -=. I have the += function, but I'm not sure how to do it backwards.
How should I go about doing this?