class Data
{
private:
int Ix;
public:
int setData(int Ivalue)
{
Ix=Ivalue;
return Ix;
}
};
int main()
{
Data MyData;
int (Data::*fnptr)(int)=&Data::setData;
int i=(MyData.*fnptr)(10);
cout<<i;
getche();
return 0;
}
plz help me to pass this function pointer to other function for some manipulation.
for Example
check(10,(MyData.*fnptr)(10))
for checking both values are same or not.
(MyData.*fnptr)(10) is not a function pointer. fnptr is. (MyData.*fnptr)(10) is just the value returned by the function fnptr points to.
Also, when you deal with function pointers, you should typedef them. It all becomes clear then.