#import <Foundation/Foundation.h>
@interface Sum:NSObject{
@public
int _num1;
int _num2;
int _result;
}
-(void)add;
@end
@implementation Sum
-(void)add{
_result = _num1 + _num2;
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
Sum *S = [Sum new];
S->_num1 = 12;
S->_num2 = 23;
[S add];
NSLog(@"S=%d",S->_result);
}
return 0;
}
为什么改程序运行时提示 [S add];这行代码有错呢?很是疑惑,老师不也是这么写的吗 |
|