- #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. |