xxxxxxxxxx
#include<iostream>
using namespace std;
class Node{
public:
int value;
Node *next;
};
void printList(Node *head){
Node *ref = head;
while(ref != nullptr){
cout << ref->value << endl;
ref = ref->next;
}
}
int main(){
// Creating our linked list initial
Node *head = new Node();
Node *second = new Node();
Node *third = new Node();
//Assign values and link
head->value = 10;
second-> value = 20;
third -> value = 30;
head->next = second;
second -> next = third;
third->next = nullptr;
xxxxxxxxxx
void print(Node *&head)
{
Node *temp = head;
while (temp != NULL)
{
cout << temp->data << " ";
temp = temp->next;
}
}