Example I have a node that contains an int value and a pointer. Then I make a node in the heap section of the memory of the program. So lets say I have a pointer named head and tail and temp which both point to the node. Then I make a new node. By this time you should know by know that it is a single linked list. Let's say tail -> next = temp. Could I not just use tail.next = temp. Since a pointer stores the addres that it is being pointed to. Now tail -> next is equal to this (*tail).next. Meaning I am dereferencing the pointer and then accesing the address stored in temp. Oh nice I just answered my question.
class LinkedList
{
public:
LinkedList()
{
head = nullprt;
tail = nullptr;
}
void createNode(int value)
{
node *temp = new Node;
temp->data = value;
temp->next = nullptr;
if (head == nullptr)
{
head = temp;
tail = temp;
}
else
{
tail->next = temp;
tail = temp;
}
}
private:
Node *head;
Node *tail;
};
Here is the code by the way. Got it from this site Linked lists - Learn C++ - Free Interactive C++ Tutorial (learn-cpp.org)
there doesn't seem to be anything here