#include <iostream> #include <functional> using namespace std; int add(int a, int b) { return a + b; } int main() { function<int (int, int)> f = add; cout<<f(100, 100)<<endl; function<int (int)> fsingle = bind(add, 123, placeholders::_1); cout<<fsingle(111)<<endl; return 0; }
跟javascript,python这类动态语言接近了