I'm having problems compiling the following program. I'm using "gcc -framework Foundation inherit8.1m" and get the following errors. What am I doing wrong? Thanks.
ld warning: in inherit8.1m, file is not of required architecture Undefined symbols: "_main", referenced from: start in crt1.10.5.o ld: symbol(s) not found collect2: ld returned 1 exit status
// Simple example to illustrate inheritance
#import <Foundation/Foundation.h>
// ClassA declaration and definition
@interface ClassA: NSObject
{
int x;
}
-(void) initVar;
@end
@implementation ClassA
-(void) initVar
{
x = 100;
}
@end
// Class B declaration and definition
@interface ClassB : ClassA
-(void) printVar;
@end
@implementation ClassB
-(void) printVar
{
NSLog (@"x = %i", x);
}
@end
int main (int argc, char *argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
ClassB *b = [[ClassB alloc] init];
[b initVar]; // will use inherited method
[b printVar]; // reveal value of x;
[b release];
[pool drain];
return 0;
}