This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]