Here I need to pass an function-pointer as an argument to a function which is pointing to the non-static member function of the class. I am using VS-2008 in Windows.
Now in .cpp file I had definitions as following and getting and compile time error message:
error C2298: '=' : illegal operation on pointer to member function expression
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Class_Func_Ptr::Class_Func_Ptr()
{
store_func_map("abc", &Class_Func_Ptr::func_1);
}
Class_Func_Ptr::~Class_Func_Ptr()
{
}
//Function has an argument as pointer to the non-static class member function.
//To store the pointed function within a std::Map.
void Class_Func_Ptr::store_func_map(std::string str_name, void (Class_Func_Ptr::*func_ptr)(std::string))
{
func_list[str_name.c_str()] = (*this.*func_ptr);
}
I will be very much thankful for the guidance, where I am doing wrong and how can I visualize the problem for better understanding.