【发布时间】:2014-08-16 21:23:46
【问题描述】:
我从我的项目中改编了三个短文件,因为它们重现了我遇到的错误:
exp.cpp
#include <iostream>
using namespace std;
int main(){
cout << "Hello world!" << endl;
}
解析器.cpp
#include <cstring>
#include "parser.h"
解析器.h
#ifndef PARSER_H_
#define PARSER_H_
#include <cstring>
class Parser{
public:
Parser(std::string*);
std::string* unprocessedInput;
};
#endif /* PARSER_H_ */
当我构建项目时,在行,
Parser(std::string*)
我在“*”标记之前收到错误消息“预期的‘)”,并且在该行,
std::string* unprocessedInput;,
我收到错误“命名空间‘std’中的‘字符串’没有命名类型”。
当我在 parser.cpp 或 parser.h 中使用
请注意,我已经对此进行了广泛的搜索。在我的研究中,我想到了在头文件中使用 std::string 而不是字符串。
【问题讨论】:
-
您知道问题所在,那么您的问题有什么意义呢?只需包含您正在执行的操作的正确标题即可。
-
我想使用以空字符结尾的字符串,这就是我想使用
的原因。如果我使用 是否意味着我需要将每个字符串都转换为 cstring?