Hi everyone

I am trying to pass a member function as an argument to another template member funtion.
But during build time i am getting an error -: error: no matching function for call to 'A::do_op(int&, int&, <unresolved overloaded function type>)'

My .h file is :

Qt Code:
  1. class A
  2. {
  3. public:
  4. A();
  5.  
  6. int test_op(int x,int y);
  7.  
  8. private:
  9. int add(int x, int y);
  10. int sub(int x, int y);
  11.  
  12. template<class F>
  13. int do_op(int x, int y, F &fun)
  14. {
  15. return fun(x,y);
  16. }
  17.  
  18. };
To copy to clipboard, switch view to plain text mode 

cpp file :

Qt Code:
  1. template<class F>
  2. int do_op_global(int x, int y, F &fun)
  3. {
  4. return fun(x,y);
  5. }
  6. int add_global(int x, int y)
  7. {
  8. return (x+y);
  9. }
  10.  
  11.  
  12. A::A()
  13. {}
  14.  
  15. int A::add(int x, int y)
  16. {
  17. return (x+y);
  18. }
  19.  
  20. int A::sub(int x, int y)
  21. {
  22. return (x-y);
  23. }
  24.  
  25. int A::test_op(int x, int y)
  26. {
  27. int m = do_op_global(x,y,add_global); // Statement 1
  28. int n = do_op(x,y,sub); // Statement 2
  29.  
  30. return (m+n);
  31. }
To copy to clipboard, switch view to plain text mode 

Only statement 2 is giving error.

Is there any restriction for template function inside class ?
Please help me how i will pass a member function as argument.

thanks.