adspace


Describe linked list using C++ with an example.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the latest version on c++?

1217


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

1172


daily Routine of father

1492


What character terminates all character array strings a) b) . c) END

1403


Can union be self referenced?

1279