zoukankan      html  css  js  c++  java
  • OC 对象和函数

    #import <Foundation/Foundation.h>

    @interface Car : NSObject

    {// 成员变量

        @public

        int wheels;

        int speed;

    }

    - (void)run;

    @end

    @implementation Car

    - (void)run

    {

        NSLog(@"%d个轮子,速度为%dkm/h的车子跑起来", wheels, speed);

    }

    @end

    void test(int w, int s)

    {

        w = 20;

        s = 200;

    }

    void test1(Car *newC)

    {

        newC->wheels = 5;

    }

    void test2(Car *newC)

    {

        Car *c2 = [Car new];

        c2->wheels = 5;

        c2->speed = 300;

        

        newC = c2;

        newC->wheels = 6;

    }

    int main()

    {

        Car *c = [Car new];

        c->wheels = 4;

        c->speed = 250;

        

        //test(c->wheels, c->speed);

        //test1(c);

        test2(c);

        

        [c run];

        

        return 0;

    }

  • 相关阅读:
    Spring Boot自动配置
    Servlet、JSP总结(1)
    Spring MVC
    Springboot中的数据库事务
    数据库访问
    AOP
    全注解下的IOC
    spring boot入门
    安卓工程化开发笔记(2)
    2048功能说明模板
  • 原文地址:https://www.cnblogs.com/oc-bowen/p/5034378.html
Copyright © 2011-2022 走看看