新手还在高中,,表示这个东西没太看懂,,,本人给一段代码看看吧,,,
一个链栈里面,,有一个
struct stack_node
{
。
};
typedef struct stack_node stack_list;
typedef stack_list *slink;
这里面的这个结构体类型是干什么用的
麻烦看看,,感激不尽
一个链栈里面,,有一个
struct stack_node
{
。
};
typedef struct stack_node stack_list;
typedef stack_list *slink;
这里面的这个结构体类型是干什么用的
麻烦看看,,感激不尽
解决方案
10
typedef给指定类型起一个别名
10
就是以后定义结构体变量时直接用后面那个别名定义声明就好
30
typedef struct stack_node stack_list;表示可以用stack_list替代struct stack_node
如:stack_list a等同于struct stack_node a;
typedef stack_list *slink;可以用slink替代stack_list *(注意*是跟着stack_list的)
如:stack_list *a等同于slink a;
http://www.cnblogs.com/afarmer/archive/2011/05/05/2038201.html
如:stack_list a等同于struct stack_node a;
typedef stack_list *slink;可以用slink替代stack_list *(注意*是跟着stack_list的)
如:stack_list *a等同于slink a;
http://www.cnblogs.com/afarmer/archive/2011/05/05/2038201.html
15
typedef
typedef type-declaration synonym;
The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition.
A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types.
Example
// Example of the typedef keyword
typedef unsigned long ulong;
ulong ul; // Equivalent to “unsigned long ul;”
typedef struct mystructtag
{
int i;
float f;
char c;
} mystruct;
mystruct ms; // Equivalent to “struct mystructtag ms;”
typedef int (*funcptr)(); // funcptr is synonym for “pointer
// to function returning int”
funcptr table[10]; // Equivalent to “int (*table[10])();”
typedef type-declaration synonym;
The typedef keyword defines a synonym for the specified type-declaration. The identifier in the type-declaration becomes another name for the type, instead of naming an instance of the type. You cannot use the typedef specifier inside a function definition.
A typedef declaration introduces a name that, within its scope, becomes a synonym for the type given by the decl-specifiers portion of the declaration. In contrast to the class, struct, union, and enum declarations, typedef declarations do not introduce new types — they introduce new names for existing types.
Example
// Example of the typedef keyword
typedef unsigned long ulong;
ulong ul; // Equivalent to “unsigned long ul;”
typedef struct mystructtag
{
int i;
float f;
char c;
} mystruct;
mystruct ms; // Equivalent to “struct mystructtag ms;”
typedef int (*funcptr)(); // funcptr is synonym for “pointer
// to function returning int”
funcptr table[10]; // Equivalent to “int (*table[10])();”