我没有用Xcode,我编译的时候说是在57行报错的,麻烦朋友们帮忙看下,哪有问题,能编译下最好,谢谢了
- #import <Foundation/Foundation.h>
- @interface Score : NSObject
- {
- int _cScore;//C语言成绩
- int _ocScore;//OC成绩
- int _totalScore;
- int _aveScore;
- }
-
- -(void)setCScore:(int)cScore;
- -(int)cScore;
- -(void)setOcScore:(int)ocScore;
- -(int)ocScore;
- -(int)totalScore;
- -(int)aveScore;
- @end
- @implementation Score
- -(void)setCScore:(int)cScore
- {
- _cScore = cScore;
- }
- -(int)cScore
- {
- return _cScore;
- }
- -(void)setOcScore:(int)ocScore
- {
- _ocScore = ocScore;
- }
- -(int)ocScore
- {
- return _ocScore;
- }
- -(int)totalScore
- {
- return _cScore + _ocScore;
- }
- -(int)aveScore
- {
- return (_cScore + _ocScore)/2;
- }
- @end
- int main()
- {
- Score *s = [Score new]
-
- [s setCScore:90];
- [s setOcScore:100];
-
- NSLog(@"总分:%d 平均分:%d",[s totalScore],[s aveScore]);
-
- return 0;
- }
复制代码 |
|