嘿所以我正在使用字符串作为键和成员函数指针作为值的映射。我似乎无法弄清楚如何添加到地图,这似乎并没有工作。C++字符串和成员函数指针的映射
#include <iostream>
#include <map>
using namespace std;
typedef string(Test::*myFunc)(string);
typedef map<string, myFunc> MyMap;
class Test
{
private:
MyMap myMap;
public:
Test(void);
string TestFunc(string input);
};
#include "Test.h"
Test::Test(void)
{
myMap.insert("test", &TestFunc);
myMap["test"] = &TestFunc;
}
string Test::TestFunc(string input)
{
}
猜测,但'&测试:: TestFunc '? – chris
似乎修复参数中的一个错误,但我仍然得到一个错误插入 – ThingWings
@Kosmo这是因为'插入'不工作的方式。 –