这是第一个&QUOT的目的;节点"在声明:QUOT; typedef结构节点{ - - - }节点;"? [英] What is the purpose of the first "node" in the declaration: "typedef struct node { - - - } Node;"?

查看:150
本文介绍了这是第一个&QUOT的目的;节点"在声明:QUOT; typedef结构节点{ - - - }节点;"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要成为与链接的数据结构更好地了解学习code例子从我的教授。

I am studying code examples from my professor in order to become better acquainted with linked data structures.

在我们的链接list.c例如教授定义了一个类型节点如下:

In our linked-list.c example the professor defines a type Node as follows:

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

什么是小写的节点的点?我是IM pression,你可以只写下,例如:

What's the point of the lower case node? I was under the impression that you could just write, for example:

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

和然后使用节点作为其自己的类型。是否有事可做的事实,如果不包含那么当编译器正在评估code就不能明白什么叫结构节点*下一个较低的情况下,节点?

and then use Node as its own type. Does it have something to do with the fact that if you don't include a lower case node then when the compiler is evaluating the code it will not be able to understand what is meant by "struct node *next"?

推荐答案

在此声明,请看下图:

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

typedef struct node Node;

这可以组合成一个单独的语句(简化报关):

This can be combined into a single statement (simplifying a declaration):

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

这篇关于这是第一个&QUOT的目的;节点"在声明:QUOT; typedef结构节点{ - - - }节点;"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆