I overloaded the operator () in one of my classes and I would like to use it in another member function.
class A {
public:
void operator()();
void operator()(double x);
};
void A::operator()() {
// stuff
};
void A::operator()(double x) {
// stuff with other members and x
this->operator();
};
The line this->operator()
does not work. I just want to use the operator I defined as a member function of my class A
. The error I get is : Error 1 error C3867: 'A::operator ()': function call missing argument list; use '&A::operator ()' to create a pointer to member
You should write:
void A::operator()(double x) {
// stuff with other members and x
this->operator()();
};
The first ()
are the name of the operator, and the second are for the call itself: that's the missing (empty) argument list from the error message.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With