rxgmoral wrote:
int get_return(int a,int b,int (*compare)());
get_return has second parameter as 'pointer to a function taking nothing returning int'.
rxgmoral wrote:
a=get_return(1,2,&Rxgmoral);
where as you are trying here to pass address of member function again having different signature. Modified code should look like this
#pragma once
class Class
{
public:
int get_return(int a,int b,int (Class::*compare)(int,int));//watch declaration of pointer
int Rxgmoral(int a,int b);
void Fun();
};
int Class::get_return(int a,int b,int(Class::*compare)(int,int))
{
return ((this->*compare)(a,b));
}
int Class::Rxgmoral(int a, int b)
{
return a+b;
}
void Class::Fun()
{
int a;
a=get_return(1,2,Rxgmoral);//no need to pass address(&)
}