Kumar P Kumar P - 2 years ago 134
Linux Question

c++ Linux compilation error

I am getting following error while compiling in linux.

file.cxx:283:9: error: reference to ‘multimap’ is ambiguous
file.cxx:273:47: error: candidates are: std::multimap, std::basic_string > multimap


->piece of sample code is

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" ) );
}
}


Thanks in advance

Answer Source

You probably have using namespace std; in the file. That means your compiler already knows "multimap", which you are trying to define again, in which case the compiler doesn't know which one you mean.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download