0

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); 
    } 
};
1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by merse
0

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?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.