C&C++类型定义typedef

1.声明

1.1结构声明:

1     struct {
2         int n;
3         double x,y;
4     };

1.2带结构标志的声明

1     struct point{
2         double x,y;
3     };

1.3定义结构类型

1.3.1  不带结构标志

typedef struct{
    POINT center;
    double radius;
}CIRCLE;

1.3.2  带结构标志  

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

2.定义结构变量

1 struct point pt1,pt2;  struct point 这类描述形式也当做类型看待

1     struct {
2         int n;
3         double x,y;
4     }st1, st2;

3总结

3.1  结构标志

  struct Node 相当于 struct {....}

3.2   typedef

       typedef struct Node Node;  用Node替代struct Node

猜你喜欢

转载自www.cnblogs.com/EarlDoss/p/8992379.html
今日推荐