Write your question here.
Can someone please explain the working of this program in detail. Especially that strict node *next.. Explain what's a node and how does it store data in it.. Even that temp->next i don't understand anything.. Please help me..Thank you in advance
#include<iostream.h>
#include<conio.h>
struct node
{
int data;
struct node*next;
}
class list
{
public:
struct node*head;
list ()
{head=NULL;}
a linked list is a data structure where nodes are attached . A node contains the pointer to the next node in the list . nodes are create in the heap , which means there are not alligned in memory opposed to arrays and vectors , that is why we need to attached them .
To access an element in the list , you have to iterate from the head until you find the corresponding node or reached the given (sort of) index.
your list should contain a node called head which is the first element and a node tail which is always equals to null . Make sure that this node is always attached to the last element of the list.
then for iterating through the list you simply do something like that :