头文件中
Objective C code?
#import
// 定义一个结构体保存生日
typedef struct {
int year;
int month;
int day;
}Date;
// 定义枚举保存性别
typedef enum{KsexMan,KsexWomen} Sex;
//// 定义数组保存学生三科成绩
//int array[3] = {0};
@interface Student : NSObject
{
NSString *_name;
Date *_birthday;
int _age;
float _height;
float _weight;
Sex *_sex;
int _markC;
int _markOc;
int _markIos;
}
@property NSString *name;
@property Date *birthday;
@property int age,markC,markOc,markIos;
@property float height,weight;
@property Sex *sex;
.m文件中
Objective C code?
#import
#import "Student.h"
int main(int argc, const char * argv[]) {
@autoreleasepool {
// 创建一个学生
Student *s = [[Student alloc] init];
Student *s1 = [[Student alloc] init];
// 设置属性
s.name = @"张三";
s.birthday->year = 1970;
s.birthday->month = 5;
s.birthday->day = 21;