【发布时间】:2011-06-21 02:24:39
【问题描述】:
我是 C++ 新手,但我不知道为什么它不能为我编译。我在 Mac 上运行,使用 Xcode 进行编码,但我正在使用自己的 bash 生成文件进行构建。
无论如何,我得到了两个编译器错误,即找不到“字符串”类型,即使我已经包含了 .欢迎任何帮助。代码:
//#include <string> // I've tried it here, too. I'm foggy on include semantics, but I think it should be safe inside the current preprocessor "branch"
#ifndef APPCONTROLLER_H
#define APPCONTROLLER_H
#include <string>
class AppController {
// etc.
public:
int processInputEvents(string input); //error: ‘string’ has not been declared
string prompt(); //error: ‘string’ does not name a type
};
#endif
我将此文件包含在我的 main.cpp 中,在 main 的其他地方我使用 string 类型,它工作得很好。虽然我主要包括iostream而不是string(用于其他目的)。是的,我也尝试在我的 AppController 类中包含 iostream,但它没有解决任何问题(我也没想到会这样)。
所以我不太确定问题出在哪里。有什么想法吗?
【问题讨论】:
标签: c++ string g++ compiler-errors