Linked storage of linear tables, the following code
typedef struct Node{
ElemType e;
struct Node *next;
}Node,*LinkList;
What is the difference between LinkList p and Node p
ringa_lee2017-06-10 09:50:45
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
.
仅有的幸福2017-06-10 09:50:45
Ifyou understand the difference between int a
and int *a
, and then understand typedef int ElemType
, you can understand the above example.
typedef struct Node{
ElemType e;
struct Node *next;
} Node, *LinkList;
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.