I’m trying to implement a simple LinkedList
The following code, producing this error:
error: lvalue required as left operand of assignment
The line is:
newNode->getNext() = _head;
Where getNext() returns a Node*, and i’m trying to make the new Node point at the current head before updating it.
I’m probably thinking in Java and doing the transition wrong.
Either, dereference:
(assuming
_headhas typeNodeand the assignment operator was implemented with care inNode) or, what is probably betterBut anyway, this is not the way you should be doing this. You may want to implement a setter.
Also, have you considered using
std::listinstead of re-inventing the wheel?