How to use a function of own class in for_each method?
Assume I have this class (inherited from std::Vector, it's just an example) #include <vector> using namespace std; template <class T> class C : public vector<T> { // I don't want to use static keyword void transformation(T i) { i *= 100; } public: void method() { for_each(this->begin(), this->end(), transformation); } }; int main() { C<double> c; for (int i=-3; i<4; ++i) { c.push_back(i); } c.method(); } How do I call for_each using class method inside class itself? I know I can use static keyword, but what is there any other way how to use a function object without using static? I get this