Definition of struct in C language:
struct struct body name {
Member list;
.....
} struct-body variables;
7.1.1 definition of struct type variables
The definition of a struct type variable is the same as the definition of other types of variables, but since the struct type needs to be defined in advance for the problem, the definition of the struct type variable increases flexibility, with a total of three forms, each of which is described as follows:
1) define the struct type and then define the struct type variables:
struct STU/* Define student structure type */
{
Char name[20]; /* Student Name */
char sex; /* Gender */
Long num; /* Study Number */
float score[3]; /* Three subjects test results */
};
struct Stu student1,student2;/* define struct type variable */
struct Stu Student3,student4;
With this struct type, you can define more of the struct type variable.
2) define struct types and define struct type variables:
struct data
{
int day;
int month;
int year;
} time1,time2;
You can also define the following variables:
struct data time3,time4;
With this struct type, you can also define more of the struct type variable.
3) directly define struct type variables:
struct
{
Char name[20]; /* Student Name */
char sex; /* Gender */
Long num; /* Study Number */
float score[3]; /* Three subjects test results */
} Person1,person2; /* Define the struct type variable */
Because the struct type cannot be logged, the struct type variable cannot be defined beyond the immediate definition
C++
typedef struct node{
int data;
struct Lnode *next;
}lnode,*linklist;
In C, if you want to define a node, you need to use struct node to define this is C + +, directly using node to define it can be Lnode is the alias node, C + + with the node effect, the declaration of the object can be used node node and Lnode node.
Linklist means node *, which refers to node's pointer declaration, linklist list and node *list effect if you do not add TypeDef, it means declaring node Lnode and node *linklist separately, declaring an object, a pointer
The definition of structure in C + +