안녕하세요, 그래서 문자열로 키와 멤버 함수 포인터를 값으로 사용하고 있습니다. 지도에 추가하는 방법을 알아낼 수 없습니다. 작동하지 않는 것 같습니다.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 이는 '삽입'이 그렇게 작동하지 않기 때문입니다. –