#import <Foundation/Foundation.h>
@interface Person : NSObject
{
@public
int age;
double height;
}
- (void)print;
@end
@implementation Person
- (void)print
{
NSLog(@"年龄=%d,身高=%f", age, height);
}
@end
int main()
{
[Person new]->age = 10;//①
[Person new]->height = 1.8;//②
[[Person new] print];//③
return 0;
}*/
①②③三部分对应的对象是不一样的,一般这种情况会在刚开始学的时候会碰到,匿名对象的内存容易泄露,性能差,不建议使用