-3

In

#include <iostream>

using namespace std;

struct node
{
    int data;
    node *next;
};

What does node *next ; mean?

Andreas Wenzel
  • 22,760
  • 4
  • 24
  • 39

1 Answers1

3

It means that the struct called node has an element called next that is of the type "pointer to node". In a linked list, such an element is typically used to point to the next entry in the linked list.

David Schwartz
  • 179,497
  • 17
  • 214
  • 278
  • Each `node` points to the *next* `node` in the list. That is what makes it a linked list. – Remy Lebeau Jun 08 '22 at 22:04
  • thanks for help , actually my doubt is that is `next` a constructor ? what is constructor. – Vishwaroop Gangarde Jun 09 '22 at 04:55
  • @VishwaroopGangarde • You are asking about very fundamental and introductory concepts in C++. It appears you are in need of a [good C++ book](https://stackoverflow.com/a/388282/4641116). – Eljay Jun 09 '22 at 11:52