欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

An Example of Using std::tr1::bind 博客分类: c++ c++ 

程序员文章站 2024-03-18 08:19:46
...
#include <iostream>
#include <tr1/functional> 
using std::tr1::bind;
using std::tr1::function;
using std::tr1::placeholders::_1;
using std::tr1::placeholders::_2;

class CTest
{
        public:
                int test( int a, int b , int c, int d)
                {   
                        return a - b + c*d;
                }   
};
int main()
{
   CTest obj;
   std::tr1::function<int(int, int)> func = bind<int>(&CTest::test, &obj, 3, 3 , _1, _2);
   int c = func(3,4);
   std::cout<< c << std::endl;
   return 0;
}
相关标签: c++