2008/12/29 19:21
[프로그래밍]
다음 코드를 실행한 결과는 무엇일까?
#import <Foundation/Foundation.h>
@interface Sequence : NSObject
{
int value;
}
@end
@implementation Sequence
- (Sequence *)next
{
value++;
return self;
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%d", value];
}
@end
int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
Sequence *seq = [[Sequence alloc] init];
NSLog(@"%@", seq.next.next.next);
[seq release];
[pool drain];
return 0;
}
참고사항: GCC 4.0과 GCC 4.2가 서로 다른 결과를 출력함
이 글은 스프링노트에서 작성되었습니다.


