/*
设计一个”学生“类
1> 属性
* 姓名
* 生日
用结构体作为类的实例变量(生日)
*/
#import <Foundation/Foundation.h>
typedef struct date
{
int year;
int montj;
int day;
}myDate;
@interface Student :NSObject
{
@public
NSString *name;
myDate _birthday;
}
@end
@implementation Student
@end
int main()
{
Student *xiaoming=[Student new];
xiaoming->name=@"xiaoming";
xiaoming->_birthday=(myDate){1992,01,01};
NSLog(@"%d",xiaoming->_birthday.year);
} |
|