匿名对象
#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;
}
|
|