외규장각 도서 환수 모금 캠페인
BLOG main image
분류 전체보기 (45)
컴퓨팅환경 (18)
프로그래밍 (18)
놀이 (2)
잡담 (7)
«   2010/03   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
10,198 Visitors up to today!
Today 27 hit, Yesterday 30 hit
daisy rss
meet me at me2DAY
나눔글꼴 내려받기
tistory
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가 서로 다른 결과를 출력함

 

이 글은 스프링노트에서 작성되었습니다.