void currentfor()
{
if(current == NULL)
{
cout << "You don't have any members yet!" << endl;
}
else
{
if (current->next == NULL)
cout << "This is the end of the list." << endl;
else
current = current->next;
}
}
void currentbac()
{
if (current == first)
cout << "This is the beginning of the list." << endl;
else
{
list *previous;
previous = first;
while (previous->next != current)
{
previous = previous->next;
}
current = previous;
}
}
I’m ALMOST there but there’s still an issue.
How do I know where my current position is when I move my current position? Because whenever I use these two move functions it doesn’t seem to be working. I try to add a node at the “current” position when I move but its always adding the item at the end after all the nodes.
PLUS in my previous code I’m not able to change the fact that the “<–current position” is pointing at all the nodes and not at one node.
I want to point to one node so its more clear that user knows that’s where the current pointer is.
Hope people understood .-. I’m just not used to C++ but my professor wants me to learn on my own ( whatever that means) I’ve been trying to get references online its so hard to get linked list info for the project I’m doing.
“I try to add a node at the “current”position when i move but its always adding at the end after all the nodes.”
The problem is with you add node code, not your moving code.
You have not posted your add node code, so it is very hard to say what the problem is. You will have to unlink the nodes before and after the new node and link them to the new node, and lso link the new node to the two old ones before and after – always remembering to handle the first and last node carefully. Have you done all that?