OC--函数的调用

王朝学院·作者佚名  2016-08-27
窄屏简体版  字體: 小  |  中  |  大  |  超大  

@interface Car : NSObject{

@public

int _wheels;

int _speed;

}

- (void)run;

@end

@implementation Car

- (void)run{

NSLog(@"%d个轮子, 速度为%d的车子跑起来了", _wheels, _speed);

}

@end

void test1(Car *newCar){

newCar->_wheels = 5;

}

void test2(Car *newCar);

int main(int argc, const char * argv[]) {

Car *c1 = [[Car alloc] init];

Car *c2 = [[Car alloc] init];

test1(c1);

test2(c2);

[c1 run];

[c2 run];

return 0;

}

void test2(Car *newCar){

newCar->_wheels = 4;

newCar->_speed = 300;

}

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝網路 版權所有 導航