时间: 2020-11-22|46次围观|0 条评论

#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这类动态语言接近了

转载于:https://www.cnblogs.com/lailailai/p/4179614.html

原文链接:https://blog.csdn.net/weixin_30342827/article/details/95858704

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《C++ 11 bind
   

还没有人抢沙发呢~