I have a static function:
void E::createEP(std::list<double>* ret, double length, double (*getHeight)(double)) {
// magic
double sampleIntervall = //from magic
double dist = 0;
while (length - dist > -0.1) {
ret->push_back(dist, (*getHeight)(dist));
dist += sampleIntervall;
}
}
In different calls I have two different functions to pass as getHeight():
- A function in a database wrapper class which is not static
- A function within the same Object of type
E
ascreateEP()
(for "recreating" with different parameters), which needs to access Elements fields and can thus not be static, either.
Is it somehow possible to pass non-static functions as parameters to a static function?
If not, what would be the most elegant alternative? I don't want to duplicate the entire code in createEP()
.