OC设计类和方法
#include <Foundation/Foundation.h>
//设计学生类和学习方法
@interface Student : NSObeject
{
@public
int age;
}
-(void)study;
@end
@implementation Student
- (void) study
{
NSLog(@"%d岁的学生在学习",age);
}
@end
int main()
{
Student *stu=[Student new];
stu->age=20;
[stu study];
}
//设计学生类和学习方法
@interface Student : NSObeject
{
@public
int age;
}
-(void)study;
@end
@implementation Student
- (void) study
{
NSLog(@"%d岁的学生在学习",age);
}
@end
int main()
{
Student *stu=[Student new];
stu->age=20;
[stu study];
}