Basically, I want to call a static function in my class which adds an entry to a static member of type std::map.
class Foo
{
private:
static std::map<std::string, int, StringCompare> mymap;
public:
static bool addEntry(std::string id);
};
std::map<std::string, int, StringCompare> Foo::mymap;
static bool Foo::addEntry(std::string id)
{
int a = 0;
return (mymap.insert ( std::pair<std::string, int> (id, a))).second;
}
EDIT: Forgot to ask the question D:
When I compile this code, it gives me the error:
derp.hpp:24:41: error: cannot declare member function ‘static bool Foo::addEntry(std::string)’ to have static linkage [-fpermissive]
What do I do?