I have an assignment about operator overloads. I did 11/13 of them, but I'm stuck on the last 2 (which are similar). I have a linked list class, and I've been assigned to overload list1+(int i)
, which I've already done. I also need to overload i+list1
, and this is where I'm having difficulties, because I also have a cout<<
overload. Examples I've found in stackoverflow caused problems with this cout operator (I'm not sure why.)
SortedDoublyLinkedList SortedDoublyLinkedList::operator+(int i)
{
SortedDoublyLinkedList newlist(*this);
newlist.add(i);
return newlist;
}
This is the piece for list+integer, but I couldn't handle the reverse case, as I described.