本帖最后由 claud0623 于 2014-9-6 17:48 编辑
看了几天OC视频,最近才开始敲代码,遇到这个程序,出现这样的错误,望各位指明如何修改:
- #import <Foundation/Foundation.h>
- @interface Person : NSObject
- {
- @public
- int age;
- double height = 1.55;
- }
- - (void)study;
- @end
- @implementation Person
- - (void)study
- {
- NSLog(@"年龄为%d的人在学习", age);
- }
- @end
- int main()
- {
- Person *p = [Person new];
- p->age = 10;
- p->height = 1.78;
- [p study];
- return 0;
- }
复制代码 用cc 文件名.c -framework Foundation编译时错误如下:
-framework: No such file or directory
Foundation: No such file or directory
m:6: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘__attribute__’ before ‘=’ token
m: In function ‘main’:
m:21: error: ‘struct Person’ has no member named ‘height’
|