#include <functional> #include <iostream>
int apply_function(std::function<int(int)> f, int x) { return f(x); }
int square(int x) { return x * x; }
class Square { public: int operator()(int x) { return x * x; } };
int main() { apply_function(square, 111); apply_function(Square(), 1111); apply_function([](int x) { return x * x; }, 11111); }
|