#import <Foundation/Foundation.h> @interface Person : NSObject { int age; } + (void)printClassName; - (void)test; + (void)test; @end @implementation Person + (void)printClassName { NSLog(@"这个类叫做Person-%d", age); } - (void)test { NSLog(@"111-%d", age); } + (void)test { NSLog(@"333"); } @end int main() { [Person *p = [Person new]; [Person printClassName]; /* ===================================== 我的问题是,上面两个[]。怎样区分上面是调用的类方法,还是用Person类创建的对象呢? [Person printClassName];计算机是怎样判断不是有Person类创建的printClassName对象呢 =====================================*/ return 0; }
|