Created
December 17, 2013 11:44
-
-
Save pbrewczynski/8003745 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 <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