本帖最后由 lanfeng0107 于 2015-4-25 11:27 编辑
应该是这样:
假如你自己定义一个结构体,是这样:
struct type
{
int a;
char b;
}
然后,不是这样用吗 --- struct type test (其实 不就类似于 int test 嘛!)
这里 struct type 就是一个结构体类型
用typedef 给 struct type 起一个别名 就叫做 type ok?
那么就是这样了: typedef struct type type ;
好,既然这是一句定义了(其实就是起名的一句话),那么 就可以用宏来替换的了
所以,干脆:
# define CLASS(type) typedef struct type type ;
ok?再定义一个结构体类型: struct type
这样,就成了:
# define CLASS(type) typedef struct type type ;
struct type
完。
|