关于继承,我这里有两个类:女性,人类的子类和人类,它可以运行但显示问题。
这里有两个问题:
main.m:29:10:“人类”可能不会响应“setSexy:”
main.m:30:10:“人类”可能不会响应“isSexy”
主文件
#import <Foundation/Foundation.h>
#import "female.h"
int main(int argc, const char * argv[])
{
@autoreleasepool {
human *sexyGirl = [[female alloc] init];
[sexyGirl setName:@"SexyGirl"];
[sexyGirl setGender:0];
[sexyGirl setSexy:1];
[sexyGirl isSexy];
}
return 0;
}
女性.h
#import "human.h"
@interface female : human {
BOOL sexy;
}
@property BOOL sexy;
-(void)isSexy;
@end
人类.h
#import <Foundation/Foundation.h>
@interface human : NSObject {
NSInteger *hp;
NSString *name;
BOOL gender;
}
@property (assign, nonatomic) NSInteger *hp;
@property (assign, nonatomic) NSString *name;
@property (assign, nonatomic) BOOL gender;
-(void) walk;
@end