Skip to content

Instantly share code, notes, and snippets.

@zorgiepoo
Created September 7, 2014 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zorgiepoo/34b9e787100572dd83c7 to your computer and use it in GitHub Desktop.
Save zorgiepoo/34b9e787100572dd83c7 to your computer and use it in GitHub Desktop.
C++ destructors and ARC
#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