[OC]匿名对象

来源:互联网 发布:三星9502支持4g网络吗 编辑:程序博客网 时间:2024/05/21 00:33
#import <Foundation/Foundation.h>@interface Person : NSObject{    @public    int age;    double height;}- (void)print;@end@implementation Person- (void)print{    NSLog(@"年龄=%d,身高=%f", age, height);}@endint main(){    [Person new]->age = 10;//①    [Person new]->height = 1.8;//②    [[Person new] print];//③    return 0;}*/

①②③三部分对应的对象是不一样的,一般这种情况会在刚开始学的时候会碰到,匿名对象的内存容易泄露,性能差,不建议使用

0 0