I want to use in my class a pointer to function.
I could not find a way.
This is a simple example that explains the difficulty:
Qt Code:
  1. class C{
  2. public:
  3. int First (int i, int j){return i;}
  4. int Second(int i, int j){return j;}
  5. int Fun(int);
  6. };
  7. int C::Fun(int i){
  8. int (C::*pFun)(int, int);
  9. if(i==1)
  10. pFun=&C::First;
  11. else
  12. pFun=&C::Second;
  13. return pFun(1,2); //ERROR
  14. }
To copy to clipboard, switch view to plain text mode 
this causes an error message to be displayed.
I cannot find a way to solve this. On the other hand the non-member version works correctly, as follows:

Qt Code:
  1. int First(int i, int j);
  2. int Second(int i, int j);
  3. int First(int i, int j){ return i;}
  4. int Second(int i, int j){ return j;}
  5.  
  6. int main (int argc, const char * argv[])
  7. {
  8. int i=1;
  9. float x;
  10. int (*fun)(int, int);
  11. if(i==1)
  12. fun=First;
  13. else
  14. fun=Second;
  15. x=fun(1,2); //OK
  16. }
To copy to clipboard, switch view to plain text mode 
Does anyone have any suggestion to give?