C 不同类型的结构
我知道struct和前面有typedef关键字的struct之间的区别。参考资料如下: vs 但这两种类型之间的区别是什么:C 不同类型的结构,c,struct,C,Struct,我知道struct和前面有typedef关键字的struct之间的区别。参考资料如下: vs 但这两种类型之间的区别是什么: struct point { int x; int y; }; vs 还有一点: typedef struct set_t{ int count; void **values; } *SetRef; 这是什么类型的 struct point { int x; int y; }; 这声明了一个新类型struct
struct point {
int x;
int y;
};
vs
还有一点:
typedef struct set_t{
int count;
void **values;
} *SetRef;
这是什么类型的
struct point { int x; int y; };
这声明了一个新类型struct point
,其中包含两个int
成员x
和y
struct point { int x; int y; } my_point;
这还声明了一个新类型
struct point
,其中包含两个int
成员x
和y
,并声明了类型struct point
的对象my_point
myu-point
是一个类型为struct-point
的变量,第一个变量声明一个struct
类型,而第二个变量同时声明类型和实例myu-point
。换句话说,my_-point
不是一个类型,而是一个实际的struct-point
实例。在第二个例子中,您还从typestruct-point定义了一个变量(名为my_-point
),第一个变量只声明了结构。以后必须使用它来创建它的对象。
第二个同时声明了它的结构和对象
typedef struct set_t{
int count;
void **values;
} *SetRef;
struct point { int x; int y; };
struct point { int x; int y; } my_point;