c++ - Beginner to learn data structure, I have a small problem
ringa_lee
ringa_lee 2017-06-10 09:48:45
0
2
889

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_lee
ringa_lee

ringa_lee

reply all(2)
左手右手慢动作

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.

仅有的幸福

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!