本帖最后由 haohaoxuexi 于 2014-4-6 23:21 编辑
- //在继承中使用构造方法
- #import <stdio.h>
- #import <Foundation/NSObject.h>
- @interface TheClass : NSObject
- static int count;//此处报错
- + (int) getCount;
- @end
- @implementation TheClass
- - (TheClass*) init
- {
- self = [super init];
- count++;
- return self;
- }
- + (int)getCount
- {
- return count;
- }
- @end
- int main()
- {
- TheClass *tc1 =[TheClass new];
- printf("TheClass count is %i\n",[TheClass getCount]);
- TheClass *tc2 = [TheClass new];
- printf("TheClass count is %i\n",[TheClass getCount]);
- return 0;
- }
复制代码 请大神门帮修改修改,老是报错它
|