Operator-- in Linked List
I am trying to overload operator-- in a singly linked list.
I have a node class with: T info nodeType *link
Iterator class (which is a friend to singly linked list) with: nodeType
*first nodeType *current bool offTheEdge
Singly Linked List class with: *first *last
I have successfully modified the operator++ method and i am passing all
the tests. The code is as follows:
if(offTheEdge == true)
{
return *this;
}
else
{
if(current->link == NULL)
{
offTheEdge = true;
return *this;
}
else
{
current = current->link;
}
}
return *this;
My instructions are as follows: Same as the operator++, but going
backwards. Going backwards in a singly linked list means you have to start
from the beginning, and identify the node behind where this->current is.
Please help, no matter what i try i am unable to get the previous elements
and work backwards. Thank you!
No comments:
Post a Comment