I have class like so
class some_class
{
public:
some_type some_value;
int some_function(double *a, double *b, int c, int d, void *e);
};
Inside some_function, I use some_values from some_class object to get a result.
So, I have a concrete object, and I want to get a pointer to this object some_function.
Is it possible? I can’t use some_fcn_ptr, because, the result of this function depends on the concrete some_value of an object.
How can I get a pointer to some_function of an object?
typedef int (Some_class::*some_fcn_ptr)(double*, double*, int, int, void*);
You cannot, at least it won’t be only a pointer to a function.
Member functions are common for all instances of this class. All member functions have the implicit (first) parameter,
this. In order to call a member function for a specific instance you need a pointer to this member function and this instance.More info here in C++ FAQ
Using Boost this can look like (C++11 provides similar functionality):
C++11’s lambdas: