黑马程序员技术交流社区

标题: 小练习 [打印本页]

作者: 许本亮    时间: 2015-11-6 11:05
标题: 小练习
#import <Foundation/Foundation.>
@interface Car : NSObject

{@public
int speed;
}

- (int)compareSpeedWithOther:(Car *)other;

@end

@implementation Car
- (int)compareSpeedWithOther:(Car *)other{
return  speed - other->speed;
}

@end

int main()
{
Car *c1 = [Car new];
c1->speed = 300;
Car2 *c2 = [Car new];
c2->speed = 280;
int a = [c1      compareSpeedWithOther:c2];
NSLog(@"a=%d",a);

return 0;
}






欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2