【问题标题】:Got so many error when compiled C++ in Xcode在 Xcode 中编译 C++ 时出现很多错误
【发布时间】:2011-10-05 19:41:29
【问题描述】:

大家

我尝试将 c++ 类添加到我的 iphone 项目中。但是我收到了很多错误消息

例如,在MyClass.h

struct DefaultData{
    char id[32];
    char name[256];
};


struct DefaultDataList{
    int size;
    //Here got a error1 : **Expected specifier-qualifier-list before "DefaultData"**
    DefaultData *dataList;
};

//Here got error 2:**Expected identifier or'(' before ':' token**
struct BookData:DefaultData{
    char class_id[32];
    char country_id[32];
    char author[128];
    char file_type[32];
    char file_size[32];
    :
    :
};

有谁知道这里发生了什么???

因为 c++ 不是我创建的...

而且我以前不会写c++,所以很迷茫……

有没有关于如何将 C++ 类导入到 object-c 的教程???

感谢您的任何回复或回答

韦伯

【问题讨论】:

标签: c++ objective-c xcode compiler-construction


【解决方案1】:

Objective-C 不支持 C++ 类 - 您需要 Objective-C++ 才能将 C++ 与 Objective-C 混合使用。

至于您的错误,您发布的代码既不是有效的 C 也不是 C++。

【讨论】:

  • 天哪....谢谢你的帮助,所以声明一个结构是错误的,对吧?
  • 您在 C++ 中正确使用了 struct,但在 C 中使用不正确。BookData 中的两个冒号在两种语言中都不正确。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-05
  • 2017-10-12
  • 1970-01-01
  • 1970-01-01
  • 2015-04-30
  • 1970-01-01
相关资源
最近更新 更多