Reputation: 15
I got a namespace in map.h header file, and defined the map in map.cpp file as
namespace mymap{
.....
}
namespace mymap{
static const map<int, string> mymap{
{0, "zero"},
{1, "one"}....
}
}
I want to access this map in another .cpp file called summary.cpp, when ever I do that the compiler throws an error mymap is not a not a member of mymap?
Why is this happening, how can I access that map in summary.cpp, I have included mymap.h in summary.cpp and using mymap::mymap to access it
Upvotes: 0
Views: 1042
Reputation: 45674
static
used on a namespace-scope definition or declaration makes it translation-unit-local.const
in the above situation would also imply static
, unless overridden with extern
.Upvotes: 0