I would try to avoid using codepad at all.
I have done a couple of tests with your code and it seems that
- it is adding an implicit (and unwanted)
using namespace std
--it does not require you to qualify map
, cout
or endl
.
- it is (probably) including more standard headers than you might want, including
#include <list>
.
That means that when the compiler looks at the code it is seeing two list
, your version and the one in std
. Because of the using directive, both are in scope in the line where you create the map and the compiler is not able to determine which to use.
Two simple things that you can do: change the name of your type for the simple test to something other than list
(ouch! the tool forcing your naming choices!) or fully qualify the use:
#include <map>
struct list {
int a,b;
};
std::map< int, ::list > the_map;
// ...
Note that codepad is adding the include by itself and the using directive, so it will also compile:
struct list {
int a,b;
};
map<int,::list> the_map;
But that piece of code is wrong