代码如下
#import <Foundation/Foundation.h>
//类的声明
@interface Car : NSObject
{
@public
int wheels;//轮胎个数
int speeds;//时速
}
@end
//类的实现
int main()
{
//初始化类
Car *p=[Car new];
p->wheels=3;
p->speeds=200;
NSLog(@"轮子个数:%d,时速:%d",p->wheels,p->speeds);
return 0;
}
仅仅就写了这么 在终端进行编译时候输入:cc 01.m -framewrok Foundation 之后。提示如下错误:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_Car", referenced from:
objc-class-ref in 01第一个oc类-e1972c.o
"_OBJC_IVAR_$_Car.speeds", referenced from:
_main in 01第一个oc类-e1972c.o
"_OBJC_IVAR_$_Car.wheels", referenced from:
_main in 01第一个oc类-e1972c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)