#import <Foundation/Foundation.h>
@interface Animal : NSObject
- (void)test1;
+ (void)test1;
@end
@implementation Animal
- (void)test1
{
NSLog(@"--test1");
}
+ (void)test1
{
NSLog(@"++test2");
}
@end
@interface Dog : Animal
- (void)test3;
@end
@implementation Dog
- (void)test3
{
NSLog(@"--test3");
[super test1];//"--test1"
}
@end
int main()
{
Dog *dog = [Dog new];
[dog test1];//--test1
[dog test2];
[dog test3];//--test3 --test1
return 0;
}
我给出的答案是[dog test1]会输出--test1,[dog test3]会输出--test3 --test1,[dog test2]完全没理由啊!求大神给个答案! |