I have a function which acts on class member function:

template <typename ClassType>
double Integral(ClassType& obj, double (ClassType::*func)(double), double lower_limit, double upper_limit)
{...}

This can be call like this from outsie:

class myclass{
public:
double classfunction(double);
};

double myclass::classfunction(double x) {...}

int main()
{
myclass probe;
std::cout << Integral(probe, &myclass::classfunction);
}

But how can I call this Integral function inside the class, from a member function?
I guess I have to use "this" but it doesnt work:

class myclass{
public:
  double classfunction(doube);
  double classint(double a, double b) 
    { 
      return Integral(this, &myclass::classint, a, b); 
    } 
};

I've found the answer to my question (replace "this" by "*this")
but I have another:
what if the classfunction is private in the example?
inside the class I can acces to it,
but how can I pass to the outside Integrand function?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.