1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| #include <Foundation/Foundation.h> @interface Car:NSObject { @public int wheels; int speed; } -(void)run;
@end @implementation Car
-(void)run { NSLog(@"%d个轮子,速度为%d km/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; }
|