I want to declare an ordinary pointer (not a member pointer) to a member function. I have tried but apparently I am getting errors. Is this allowed in C++? Why is it not?
#include<iostream>
class A{
private:
int m;
public:
void show(void){
std::cout<<"M= "<<m<<std::endl;
}
};
int main()
{
A a;
void (*ptr)(void);
ptr = a.show;
*ptr;
return 0;
}
The error I am getting is: argument of type ‘void (A::)()’ does not match ‘void (*)()’