Created
May 14, 2009 02:31
-
-
Save akio0911/111434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Cocoa/Cocoa.h> | |
@interface Child : NSObject { | |
} | |
- (id)init; | |
- (void)dealloc; | |
@end | |
@implementation Child | |
- (id)init | |
{ | |
NSLog(@"Child init"); | |
if(self = [super init]){ | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
NSLog(@"Child dealloc"); | |
[super dealloc]; | |
} | |
@end | |
@interface Parent : NSObject { | |
Child * child; | |
} | |
- (id)init; | |
- (void)dealloc; | |
@end | |
@implementation Parent | |
- (id)init | |
{ | |
NSLog(@"Parent init"); | |
if(self = [super init]){ | |
child = [[Child alloc] init]; | |
} | |
return self; | |
} | |
- (void)dealloc | |
{ | |
NSLog(@"Parent dealloc"); | |
[child release]; | |
[super dealloc]; | |
} | |
@end | |
int main(){ | |
Parent * parent = [[Parent alloc] init]; | |
[parent release]; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment