typedef(起别名)
1 普通变量
typedef int myInt;
后面就可以用myInt代替int定义变量了,效果相同
2 结构体变量
1) Struct Person
{
int age;
char *name;
}
typedef Struct Person myPerson;
2) typedef Struct Person
{
int age;
char *name;
}myPerson;
3) typedef Struct
{
int age;
char *name;
}myPerson;
3 指针变量
typedef char * String;
4 枚举
1) enum Gender
{
kGenderMale,
kGenderFemale
}
typedef enum Gender sex;
2) typedef enum Gender
{
kGenderMale,
kGenderFemale
}sex;
3) typedef enum
{
kGenderMale,
kGenderFemale
}sex;
5 指向函数的指针
typedef int(*functionPointer)(int,int);(说明:functionPointer就是其别名)
此时该指针就可以指向诸如int sum(int v1,int v2)类型的函数,
functionPointer sumP=sum;