#embody <iostream>
utilizing namespace std;
class Node {
public:
int information;
Node* subsequent;
Node(int information)
{
this->information = information;
this->subsequent = NULL;
}
~Node()
{
int worth = this->information;
if (this->subsequent != NULL) {
delete subsequent;
this->subsequent = NULL;
}
}
};
void insertAtTail(Node*& tail, int d)
{
Node* temp = new Node(d);
tail->subsequent = temp;
tail = temp;
}
void print(Node*& head)
{
Node* temp = head;
whereas (temp != NULL) {
cout << temp->information << " ";
temp = temp->subsequent;
}
cout << endl;
}
Node* createPointer(Node*& head)
{
Node* dummy = new Node(-1);
dummy->subsequent = head;
return dummy;
}
int fundamental()
{
Node* node = new Node(1);
Node* head = node;
Node* tail = node;
insertAtTail(tail, 2);
insertAtTail(tail, 3);
insertAtTail(tail, 4);
insertAtTail(tail, 5);
cout << "Linked Listing: " << endl;
print(head);
Node* pt = createPointer(head);
cout
<< "Dummy pointer pointing to move of Linked Listing: "
<< endl;
print(pt);
return 0;
}