I'm trying to do something like
class base { public: virtual double operator() (double val) = 0; virtual double operator() (double prev, double val) { return prev + operator()(val); } }; class derived: public base { virtual double operator() (double val) { return someting_clever; } };
I want to overload the operator () to use it with various algorithms such as std :: accumulate or std :: transform. I am completely satisfied with the definition of the base class operator () (double, double). However, I cannot call it from a derived class. Do I have to rewrite the same code for each class that I get from the database?
source share