linuxでコンパイル中に次のエラーが発生します。C++ Linuxコンパイルエラー
file.cxx:283:9: error: reference to ‘multimap’ is ambiguous
file.cxx:273:47: error: candidates are: std::multimap, std::basic_string > multimap
- サンプルコードの>の部分はおそらく、ファイルにusing namespace std;
を持って事前
linuxでコンパイル中に次のエラーが発生します。C++ Linuxコンパイルエラー
file.cxx:283:9: error: reference to ‘multimap’ is ambiguous
file.cxx:273:47: error: candidates are: std::multimap, std::basic_string > multimap
- サンプルコードの>の部分はおそらく、ファイルにusing namespace std;
を持って事前
で
static std::multimap<std::string,std::string> multimap; //line no. 273
//
void foo()
{
if (multimap.size() == 0)
{
multimap.insert(std::pair< std::string, std::string >("A" , "B"));
}
}
おかげです。これは、コンパイラが既に定義している "マルチマップ"を既に知っていることを意味します。
標準のメンバーがあり、あなたの名前空間にそれを挿入しました。あなたがこの方法を必要とするものをインポートすることができusing namespace std;
を使用しないでください:
using std::multimap;
using std::string;
あなたはstd名前空間を使用して '持っています;'ファイルの先頭に? – TartanLlama
一般的な(簡単な)アドバイス:標準ライブラリコンポーネントと同じ名前の識別子は使用しないでください。 – kebs
@kebsそのようなアドバイスの理由はありません。代わりに 'using namespace std'や' std :: whatever'を使用しないでください。 – rubenvb