Trying to edit a node in a linked list, the "next node" is inside the private section of my node class, i added a method which only returns the Node* in the public in order to edit it when i need to, and i get an error it's modifiable.
Before i moved the next node pointer to the private section it was inside my public section and worked fined, i don't understand what's the difference between editing the "Node* next" directly or editing "Node* getNext()" which returns exactly the same thing, the Node* next.
Here's some of the relevant code:
class Node;
//Node class
class Node
{
private:
Client* client;
Node* next;
public:
Node();
Node(Client*);
Node(Client*,Node*);
~Node();
Client* getClient();
Node* getNext();
};
//end of Node class
The getters:
Client* MatchmakingAgency::Node::getClient(){
return client;
}
MatchmakingAgency::Node* MatchmakingAgency::Node::getNext(){
return next;
}
and the function that returns the error: (2nd line)
void MatchmakingAgency::addNode(Client* data){
(nodeTail->getNext()) = new Node(data);
nodeTail = nodeTail->getNext();
}
Error message:
Error 1 error C2106: '=' : left operand must be l-value