Describe linked list using C++ with an example.



Describe linked list using C++ with an example...

Answer / Dinesh Singh

A linked list in C++ is a linear data structure consisting of nodes that store data and a pointer to the next node. Each node can be thought of as a separate memory location with its own variables, including a data member and a pointer to the next node. An example of a simple singly-linked list could look like this:

```cpp
struct Node {
int data;
Node* next;
};

void insert(Node** head_ref, int new_data) {
Node* new_node = new Node();
new_node->data = new_data;
new_node->next = (*head_ref);
(*head_ref) = new_node;
}
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

write asingle linked list which read from two list & the do the following 1 sort the prime & nonprime num (prime should be less tn nonprime) 2 each node has a prime num followd by nonprime 3 add a new node into its sutable plce 4 erase the most three duplicated non prime num 5 find the least duplicated prime num

1 Answers   Care,


Which should be more useful: the protected and public virtuals?

1 Answers  


plz send me National informatics center paper pattern

1 Answers  


What is the difference between global variables and static varables?

1 Answers  


Why main function is special in c++?

1 Answers  


How does a C++ structure differ from a C++ class?

1 Answers   NIIT,


What's the most powerful programming language?

1 Answers  


What header file is needed for exit(); a) stdlib.h b) conio.h c) dos.h

1 Answers  


What is an inline function in c++?

1 Answers  


What is the real purpose of class – to export data?

1 Answers  


Why is c++ so fast?

1 Answers  


Can inline functions have a recursion? Give the reason?

3 Answers  


Categories