Created
September 7, 2014 02:39
-
-
Save zorgiepoo/34b9e787100572dd83c7 to your computer and use it in GitHub Desktop.
C++ destructors and ARC
This file contains 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 "ZZGAppDelegate.h" | |
@interface Foo : NSObject | |
@end | |
@implementation Foo | |
- (void)dealloc | |
{ | |
NSLog(@"HI"); | |
} | |
@end | |
class Bar | |
{ | |
public: | |
Bar() | |
{ | |
baz = [[Foo alloc] init]; | |
} | |
private: | |
Foo *baz; | |
}; | |
@implementation ZZGAppDelegate | |
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification | |
{ | |
Bar meh; // will print HI when stack is popped | |
Bar *gah = new Bar; | |
delete gah; // will print HI when gah is deleted | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment