| 1 | #import <Foundation/Foundation.h> |
| 2 | |
| 3 | @interface MyBaseClass : NSObject |
| 4 | {} |
| 5 | -(id) init; |
| 6 | -(int) getInt; |
| 7 | @end |
| 8 | |
| 9 | @implementation MyBaseClass |
| 10 | - (id) init { |
| 11 | return (self = [super init]); |
| 12 | } |
| 13 | |
| 14 | - (int) getInt { |
| 15 | return 1; |
| 16 | } |
| 17 | @end |
| 18 | |
| 19 | @interface MyDerivedClass : MyBaseClass |
| 20 | { |
| 21 | int x; |
| 22 | int y; |
| 23 | } |
| 24 | -(id) init; |
| 25 | -(int) getInt; |
| 26 | @end |
| 27 | |
| 28 | @implementation MyDerivedClass |
| 29 | - (id) init { |
| 30 | self = [super init]; |
| 31 | if (self) { |
| 32 | self-> x = 0; |
| 33 | self->y = 1; |
| 34 | } |
| 35 | return self; |
| 36 | } |
| 37 | |
| 38 | - (int) getInt { |
| 39 | y = x++; |
| 40 | return x; |
| 41 | } |
| 42 | @end |
| 43 | |
| 44 | |
| 45 | int main (int argc, char const *argv[]) |
| 46 | { |
| 47 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; |
| 48 | NSObject* object = [[MyDerivedClass alloc] init]; |
| 49 | MyBaseClass* base = [[MyDerivedClass alloc] init]; |
| 50 | [pool release]; // Set breakpoint here. |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | |