什么是类型定义
typedef是一个高级数据特性,它可以为某一类型自定义名称,即类型的别名。
为什么要使用类型定义
1.简化写法
2.提高程序的可移植性
与宏定义的差别
typedef char * STRING ;
#define STR char *
STRING s1, s2; //等同于char *s1 , char *s2; STRING规定了类型
STR s3, s4; //等同于char * s3, s4; STR就是简单的替换,s3是指针,s4是字符变量
typedef int DataType;
可以如下使用:
DataType DataType;
或者 DataType* DataType;