| 复制代码#import <Foundation/Foundation.h>
@interface Car : NSObject
{
        @public 
        int speed;
}
- (int) compareSpeedWithOther : (Car *)other;
@end
@implementation Car 
- (int)compareSpeedWithOther :(Car *)other // Äãд´íÁË£¬ÊÇ(Car *)ÀàÐ굀 ²»ÊÇ (Catr *)
{
        return speed - other->speed;
}
@end
int main()
{
        Car * c1 = [Car new];
        c1->speed = 300;
        Car * c2 = [Car new];
        c2->speed = 280;
        int chaju =[c1 compareSpeedWithOther : c2];
        NSLog(@"the chaju is %d",chaju);
        return 0;
}
以上是自己凭记忆写的,我没有编译器,也不知道到底正确不正确,楼主自己试试吧
 |