- #import <Foundation/Foundation.h>
- @interface Car :NSObject
- {
- @public
- int wheels;
- int speed;
- }
- -(void)run;
- void test(int w ,int s);
- @end
- @implementation Car
- -(void)run
- {
- NSLog(@"%d个轮子,时速为%dKm/h的车子跑起来了",wheels,speed);
- }
- @end
- void test(int w ,int s)
- {
- w =20;
- s =5;
- }
- int main()
- {
- Car *p=[Car new];
- p->wheels = 4;
- p->speed = 200;
- test(p->wheels,p->speed);
- [p run];
- return 0;
- }
复制代码
编译连接时出现问题:
localhost:11-OC mazhihua$ cc 09-OC对象和函数.m
Undefined symbols for architecture x86_64:
"_NSLog", referenced from:
-[Car run] in 09-OC对象和函数-83cd7b.o
"_OBJC_CLASS_$_NSObject", referenced from:
_OBJC_CLASS_$_Car in 09-OC对象和函数-83cd7b.o
"_OBJC_METACLASS_$_NSObject", referenced from:
_OBJC_METACLASS_$_Car in 09-OC对象和函数-83cd7b.o
"___CFConstantStringClassReference", referenced from:
CFString in 09-OC对象和函数-83cd7b.o
"__objc_empty_cache", referenced from:
_OBJC_METACLASS_$_Car in 09-OC对象和函数-83cd7b.o
_OBJC_CLASS_$_Car in 09-OC对象和函数-83cd7b.o
"_objc_msgSend", referenced from:
_main in 09-OC对象和函数-83cd7b.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
localhost:11-OC mazhihua$
看不懂问题,不会解决,求指教!! |
|