In line 35 what is meaninf of n-->

in line 35 what is meaninf of n–>

“->” is referred to as an arrow operator and is used to dereferencing a pointer, so the syntax is the same as (*ptr). Dereferencing a pointer means to get the value of that address, so for example:

struct Person{

string name;

int age;

};

Person *Bob = new Person;

Bob -> age = 21;

sir is node is a deafault keyword

no…it was the name of the class you created in the implementation of linked list. Check the code.

in line 7 how we are writtiong node*next;what it is mean node is a class

Each element of the linked list is a node…whose structure has been defined in the code (where the node class was made).
Each node in a linked list has 2 main components:
first is the data which it holds
second one is the address of the next node to which it is connected.

To store an address you must know that you have to use pointer variable.
so node * next is the component used to store the address of the next node to which the current node points.
Since the next node to which the current node will point is also of the type node(as this will also store a data and an address of next node)…so the data type of next is node *. Please refer the video again for more clarity.

i didnot understand anything even revising my pointer and dynamic memory allocation . how to approach this correctly

in line 33 we are doind noden but we diidnt declare n in class noden;

node*n in line 33 we used

https://ide.codingblocks.com/s/211425 why it is showing segementation ffault

@Aditya-Kushwaha-914550392281281 https://ide.codingblocks.com/s/211430
Check now…I have commented in the code.

in function void print will u please elaborate while loop

To begin with, you store the head in temp variable.
Withing the while loop, you traverse the list one node after another.So at the end of each iteration, you update temp to temp->next

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

what is the mean of the line node * temp =head is it storing the address of head poiinteer or if it doing this than why is is not written as node * temp =&head