OK I have solved the problem:
#include<iostream>
#include<complex>
using namespace std;
//#include"/home/benjamin/diplomaProg/headers/ComplexUnit.h"
//#include"/home/benjamin/diplomaProg/headers/Derivator.h"
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(&Uporaba::sestej,a,b);
}
};
int main(){
Uporaba inst = Uporaba();
cout << inst.rezultat(1,2) << endl;
return 0;
}
But is this the most elegant way?
--- Begin Message ---
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
--- End Message ---