gpt4 book ai didi

c++ unordered_map 与 g++ 的编译问题

转载 作者:可可西里 更新时间:2023-11-01 18:41:45 25 4
gpt4 key购买 nike

我在 Ubuntu 中使用 g++

g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

我有这个代码

#include<unordered_map>
using namespace std;

bool ifunique(char *s){
unordered_map<char,bool> h;
if(s== NULL){
return true;
}
while(*s){
if(h.find(*s) != h.end()){
return false;
}
h.insert(*s,true);
s++;
}
return false;
}

当我编译时使用

g++ mycode.cc

我遇到了错误

 error: 'unordered_map' was not declared in this scope

我错过了什么吗?

最佳答案

如果您不想在 C++0x 模式下编译,请将 include 和 using 指令更改为

#include <tr1/unordered_map>
using namespace std::tr1;

应该可以

关于c++ unordered_map 与 g++ 的编译问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3973659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com