黑马程序员技术交流社区
标题:
第一个程序就开始报错 求大神找原因
[打印本页]
作者:
zzyy3321
时间:
2014-9-18 11:30
标题:
第一个程序就开始报错 求大神找原因
#import <Foundation/Foundation.h>
// 颜色
typedef enum {
ColorBlack,
ColorGreen,
ColorBlue,
ColoeRed
} Color;
// 性别
typedef enum {
SexMan,
SexWoman,
SexUnknow
} Sex;
@interface Dog : NSObject
{
@public
Color color; // 颜色
int speed; // 速度
Sex sex; // 性别
double weight; // 体重
}
- (void)eat; // 吃
- (void)bark; // 吠
- (void)run; // 跑
- (BOOL)isSameColorWithOther:(Dog *)other; // 比较是否为相同颜色
- (int)compareSpeedWithOther:(Dog *)other; // 比较速度差
@end
@implementation Dog
@end
int main (){
return 0;
}
复制代码
报错如下:
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.
作者:
___________H
时间:
2014-9-18 12:25
只是警告。。。。。没写方法实现
作者:
zhuiyi007
时间:
2014-9-18 12:38
只是警告,不影响程序运行
作者:
qiusiyu
时间:
2014-9-18 12:45
method definition for 'eat' not found : 方法定义没有找到
说明你声明了数个行为,但是编译程序没有找到对应的行为实现,所以会给你一个警告。
等你下一步学会了 @implementation 类名
行为实现
@end
就好了。
作者:
zzyy3321
时间:
2014-9-18 13:44
加了实现之后好了,小白真可怕啊。
作者:
黎寻芳茴
时间:
2014-9-18 14:30
08行 这个单词 ColoeRed 打错了吧?
作者:
七年级生
时间:
2014-9-18 15:01
我也学到这了 像前面说的那样 没方法的实现。。。
作者:
★彬★卍囧神
时间:
2014-9-18 21:02
代码书写什么的还可以,不错哦加油!!!
作者:
SailY
时间:
2014-9-19 00:07
- (void)eat
{
}
如果跟我一样有强迫症的话,可以把这个先加上
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2