在object-c中枚举的类型只能是整形比如int long short bool(true和false本质上是1和0)等。
struct结构体中的数据不能赋初值,所以赋值只能通过声明加入的方式。
#import <Foundation/Foundation.h>
enum sex{
male=0,
female=1
};
typedef enum{
c=3,
d=4
}test2;
struct student {
char* name;
enum sex sex;
int age;
};
typedef struct student stu;
int main(int argc, const char * argv[])
{
stu su;
su.name="wen";
su.sex=male;
NSLog(@"name=%s,sex=%d",su.name,su.sex);
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
}
return 0;
}