首页 > 编程语言 > 详细

C++ 11 bind

时间:2014-12-23 12:08:55      阅读:322      评论:0      收藏: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这类动态语言接近了

C++ 11 bind

原文:http://www.cnblogs.com/lailailai/p/4179614.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!