Sorry, I have had a break from Objective C so I am going through this book making practice code because the book fails to put in exercises.
I have become frustrated as I am not able to get the class Second to inherit from the class first!
I also get a warning on [second print] saying second may not respont to -print and another warning on Second *second = [[Second alloc] init];
saying Second may not respond to +alloc
Finally, my actual error says it cannot find interface decleration for 'First', superclass of 'Second'.
This is my code and I would be really grateful if someone could point out the error.
Code:
#import <Foundation/Foundation.h>
@interface Second : First
{
}
@end
@implementation Second
@end
////////////////////////////////////////////////////////////////////////////////////
@interface First : NSObject
{
}
-(void) print;
@end
@implementation First
-(void) print
{
NSLog(@"Test");
}
@end
////////////////////////////////////////////////////////////////////////////////////
int main (){
First *first = [[First alloc] init];
Second *second = [[Second alloc] init];
[second print];
[first print];
return 0;
}