这一直困扰着我.我正在尝试创建一个带有哈希表的函数,并返回所述哈希表.但是我在头文件中收到此错误,
error: ‘string’ was not declared in this scope.
error: template argument 1 is invalid
Run Code Online (Sandbox Code Playgroud)
这是头文件本身:
#ifndef NAME_SPAWN_H
#define NAME_SPAWN_H
#include <QString>
#include <QHash>
#include <string>
class Name_Spawn
{
public:
Name_Spawn();
void initalize();
private:
QString int_2_str(int);
void seed();
QHash<string,QString> setTable(QHash<string,QString>);
};
#endif // NAME_SPAWN_H
Run Code Online (Sandbox Code Playgroud)
如您所见,已声明字符串.有任何想法吗?我没办法.
真正的名字string是std::string.尝试使用它.
(std::只有using namespace std;在范围内有指令时才可以省略限定符.但是不要放入using namespace std;头文件是个好习惯.)
| 归档时间: |
|
| 查看次数: |
982 次 |
| 最近记录: |