I've a scenario as below code. I'm trying to
Store the address of a C++ member function in a vector of function pointers.
access a C++ member function using this vector of function pointers.
I am able to add the functions, but I can't call them. The error I get is:
error: must use '.' or '->' to call pointer-to-member function in
class allFuncs {
private:
std::vector<void *(allFuncs::*)(int)> fp_list; // Vector of function pointers
void func_1(int a) {
// some code
}
void func_2(int a) {
// some code
}
void func_3() {
// STORING THE FUNCTION POINTER INTO The VECTOR OF FUNCTION POINTERS
fp_list.push_back(&func_2);
fp_list.push_back(allFuncs::func_1);
}
func_4() {
// Calling the function through the function pointer in vector
this->*fp_list.at(0)(100); // this does not work
}
}