A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© zzyy3321 中级黑马   /  2014-9-18 11:30  /  1896 人查看  /  8 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. #import <Foundation/Foundation.h>

  2. // 颜色
  3. typedef enum {
  4.     ColorBlack,
  5.     ColorGreen,
  6.     ColorBlue,
  7.     ColoeRed
  8. } Color;

  9. // 性别
  10. typedef enum {
  11.     SexMan,
  12.     SexWoman,
  13.     SexUnknow
  14. } Sex;

  15. @interface Dog : NSObject
  16. {
  17. @public
  18.     Color color; // 颜色
  19.     int speed; // 速度
  20.     Sex sex; // 性别
  21.     double weight; // 体重
  22. }
  23. - (void)eat; // 吃
  24. - (void)bark; // 吠
  25. - (void)run; // 跑
  26. - (BOOL)isSameColorWithOther:(Dog *)other; // 比较是否为相同颜色
  27. - (int)compareSpeedWithOther:(Dog *)other; // 比较速度差
  28. @end

  29. @implementation Dog

  30. @end

  31. int main (){
  32.    
  33.    
  34.     return 0;
  35. }
复制代码



报错如下:
1.m:34:17: warning: method definition for 'eat' not found
      [-Wincomplete-implementation]
@implementation Dog
                ^
1.m:27:1: note: method 'eat' declared here
- (void)eat; // 吃
^
1.m:34:17: warning: method definition for 'bark' not found
      [-Wincomplete-implementation]
@implementation Dog
                ^
1.m:28:1: note: method 'bark' declared here
- (void)bark; // 吠
^
1.m:34:17: warning: method definition for 'run' not found
      [-Wincomplete-implementation]
@implementation Dog
                ^
1.m:29:1: note: method 'run' declared here
- (void)run; // 跑
^
1.m:34:17: warning: method definition for 'isSameColorWithOther:' not found
      [-Wincomplete-implementation]
@implementation Dog
                ^
1.m:30:1: note: method 'isSameColorWithOther:' declared here
- (BOOL)isSameColorWithOther:(Dog *)other; // 比较是否为相同颜色
^
1.m:34:17: warning: method definition for 'compareSpeedWithOther:' not found
      [-Wincomplete-implementation]
@implementation Dog
                ^
1.m:31:1: note: method 'compareSpeedWithOther:' declared here
- (int)compareSpeedWithOther:(Dog *)other; // 比较速度差
^
5 warnings generated.

评分

参与人数 1技术分 +1 收起 理由
★彬★卍囧神 + 1 赞一个!

查看全部评分

8 个回复

倒序浏览
只是警告。。。。。没写方法实现
回复 使用道具 举报
只是警告,不影响程序运行
回复 使用道具 举报
method definition for 'eat' not found   :  方法定义没有找到

说明你声明了数个行为,但是编译程序没有找到对应的行为实现,所以会给你一个警告。

等你下一步学会了    @implementation 类名
                                    行为实现
                                    @end
就好了。
回复 使用道具 举报
加了实现之后好了,小白真可怕啊。
回复 使用道具 举报
08行  这个单词 ColoeRed  打错了吧?   
回复 使用道具 举报
我也学到这了  像前面说的那样  没方法的实现。。。
回复 使用道具 举报
代码书写什么的还可以,不错哦加油!!!
回复 使用道具 举报
SailY 中级黑马 2014-9-19 00:07:50
9#
- (void)eat
{

}
如果跟我一样有强迫症的话,可以把这个先加上
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马