A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

本帖最后由 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;
        }

4 个回复

倒序浏览
好麻烦的样子,如果能简化一下最好,你能把这个搞好了你一定会收益很多的~~
回复 使用道具 举报
先收藏了   
回复 使用道具 举报
楼主的方法不错 学习了
回复 使用道具 举报
沙睿 来自手机 中级黑马 2015-6-24 21:39:56
报纸
楼主方法不错,已学习
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马