I read a lot of posts and answers about pointers to non-static member functions, but no one can solve my problem.
Therefore, I created a short example to replicate my problem here: even if this example can be "solved" in different ways, it is important for the final software to maintain the structure, as in the example, thanks.
This is the title of the "Funcs.h" class:
class Funcs
{
private:
double a = 1, b = 2;
public:
Funcs();
~Funcs();
double Fun1(double X);
double solver(double X0);
double aaa(double(*fun)(double), double x0);
};
This is the cpp class "Funcs.cpp":
#include "Funcs.h"
using namespace std;
Funcs::Funcs()
{
}
Funcs::~Funcs()
{
}
double Funcs::Fun1(double X) {
double f1 = a*X;
return f1;
}
double Funcs::solver(double X0)
{
double result;
result = aaa(Fun1, X0);
return result;
}
double Funcs::aaa(double(*fun)(double), double x0)
{
return fun(x0);
}
And finally, this is the main "main.cpp":
#include <iostream>
#include "Funcs.h"
using namespace std;
int main() {
double x0=1;
double result;
Funcs funcs;
result = funcs.solver(x0);
cout << result << endl;
return 0;
}
Funcs:: solver, "result = aaa (Fun1, X0)"; Fun1, . , "" .
.