class sortedList
{
class Node
{
public:
int value;
Node* next;
Node()
{
this->value = 0;
this->next = NULL;
}
Node(int value)
{
this->value = value;
this->next = NULL;
}
}* head = NULL, * tail = NULL;
public:
void addNode(int value)
{
Node* n = Node(value);
//More code...
}
};
Why does adding new
before Node(value)
make the code correct?
I think the code above should stay wrong because pointer doesn't equal a node.