作为一个初学者,我正在学习关于链表和其他数据结构的C++知识。在查看了一些在线实现后,我发现了这两种定义struct的方式。它们之间有什么区别呢?其中一种在下一个指针前添加了“struct”,而另一种则没有。
struct Node { int data; Node* next; };
方式1:
struct Node { int data; Node* next; };
Way 2:
struct Node { int data; struct Node* next; };struct node
{
int data;
node *next;
};
方式二:
struct node
{
int data;
struct node *next;
};