3.6 typedef int x[10]和#define x int[10]的区别
/*typedef看成是一种彻底的“封装”类型----在声明它之后不能再往里面增加别的
*内容,可以用其他类型说明符对宏类型名进行扩展,但对typedef所定义的类型却不能那样做
*/
#define peach int
unsigned peach i; /*没问题*/
typedef int banana;
unsigned banana i; /*错误!非法*/
/*在几个连续的变量的声明中,用typedef定义的类型能够保证声明中所有的变量均为
*同一种类型,而用#define定义的类型却无法保证
*/
#define int_ptr int *
int_ptr chalk, cheese;
相当于
int *chalk, cheese;
typedef char * char_ptr;
char_ptr Bentley, Rolls_Royce;
相当于
char * Bentley, *Rolls_Royce;