This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to take the member function as the function argument?
- From: benjamin <benjamin dot batistic at triera dot net>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 15 Feb 2007 01:55:30 +0100
- Subject: How to take the member function as the function argument?
I have a simple test program:
#include<iostream>
using namespace std;
class Uporaba
{
private:
double sestej(double a,double b){
return a+b;
}
double naredi(double (Uporaba::*F)(double,double),double a, double b){
double c;
c = (this->*F)(a,b);
return c;
}
public:
Uporaba(){}
double rezultat(double a,double b){
return naredi(sestej,a,b);
}
};
int main(){
Uporaba inst = Uporaba();
cout << inst.rezultat(1,2) << endl;
return 0;
}
Compiler gives an error:
error: no matching function for call to 'Uporaba::naredi(<unknown
type>,double&,double&)'
What is wrong? Please help.
Benjamin