刚看到视频中用到组合,组合的格式指什么?
上一个有相同属性的类名 * 类名;
上一个有相同属性的类名 * 属性名;
例如这个:组合那该写什么? Score *_score; 这个_score代表什么
- @interface Score : NSObject
- {
- int _cScore;
- int _ocScore;
- }
- @end
- @implementation Score
- @end
- @interface Student : NSObject
- {
- // 组合
- Score *_score;
- // int _cScore;
- // int _ocScore;
- int _age;
- }
- @end
- @implementation Student
- @end
复制代码 |
|