Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created December 17, 2013 11:44
Show Gist options
  • Save pbrewczynski/8003745 to your computer and use it in GitHub Desktop.
Save pbrewczynski/8003745 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface Vehicle : NSObject
- (void) move;
@end;
@implementation Vehicle
- (void) move {
NSLog(@"I move");
}
@end
@interface Ship : Vehicle
- (void)shoot;
@end
@implementation Ship
- (void) shoot {
NSLog(@"I shoot");
}
@end
int main(int argc, const char * argv[])
{
@autoreleasepool {
// insert code here...
NSLog(@"Hello, World!");
Ship *s = [[Ship alloc] init];
[s shoot];
[s move];
Vehicle* v = s;
[v shoot]; // on the stanford course, they said this would just make an warning/ not compile error that you CAN'T ignore. BTW: This should work, since "v" is realy Ship.
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment