本帖最后由 S970028126 于 2015-6-24 20:14 编辑
# import <Foundation/Foundation.h>
@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;
Car *c2 = [Car new];
c2->speed = 280;
int a = [c1 compareSpeedWithOther:c2];
NSLog (@"a=%d", a);
return 0;
} |
|