OC 结构体的应用

#import 
typedef struct{
    int year;
    int month;
    int day;
}MyDate;

@interface Student:NSObject{
    @public
    NSString *_name;
    MyDate _date;
}
@end

@implementation Student



@end



int main(int argc, const char * argv[])
{

    @autoreleasepool {

        Student *stu = [Student new];
        stu ->_name = @"tom";
        stu ->_date = (MyDate){2012,12,22};

        MyDate d = {2222,11,11};
        stu ->_date = d;

        NSLog(@"year = %d,month = %d, day = %d", stu->_date.year, stu->_date.month, stu->_date.day);

        struct Car{
            int _wheel;
            int _speed;
        }car;

        car = (struct Car){22,22};

        NSLog(@"Hello, World!");

    }
    return 0;
}

你可能感兴趣的:(Objective,C基础)