LinkList is a pointer type, Node is a structure type. LinkList Pointer type variables can be used with (*p).e or p->e,Node type variables You can use p.e.
First of all, from the outside, typedef [] *** is to redefine the type in [] to be represented by ***; in the example, it means that the intermediate structure type The variable struct Node{***} can be represented here by Node and *LinkList. Moreover, When you need to declare a Node variable, you can use Node p to declare it; it is equivalent to struct Node p When you need to declare a Node pointer variable, you can use LinkList p to declare; equivalent to struct Node *p
Look at the structure definition in the middle: defines a structure type with the alias Node: This structure consists of a ElemType type variable e and a current structure type pointer *next Then every variable of this structure type you declare contains these two elements.
LinkList
is a pointer type,Node
is a structure type.LinkList
Pointer type variables can be used with(*p).e
orp->e
,Node
type variables You can usep.e
.Ifyou understand the difference between
int a
andint *a
, and then understandtypedef int ElemType
, you can understand the above example.First of all, from the outside,
typedef [] ***
is to redefine the type in[]
to be represented by***
;in the example, it means that the intermediate structure type The variable
struct Node{***}
can be represented here byNode
and*LinkList
. Moreover,When you need to declare a
Node
variable, you can useNode p
to declare it; it is equivalent tostruct Node p
When you need to declare a
Node
pointer variable, you can useLinkList p
to declare; equivalent tostruct Node *p
Look at the structure definition in the middle:
defines a structure type with the alias
Node
:This structure consists of a
ElemType
type variablee
and a current structure type pointer*next
Then every variable of this structure type you declare contains these two elements.