我想从Wrox 的 Professional C++编译这个简单的 test.cpp 程序:
#include<iostream>
#include<functional>
using namespace std;
void func(int num, const string& str)
{
cout << num << ' ' << str << endl;
}
int main()
{
string str = "abc";
auto f = bind(func, placeholders::_1, str);
f(16);
}
我有 g++ (Debian 4.4.5-8) 4.4.5 编译器,我像这样使用它:
g++ -std = c++0x test.cpp -o test
我得到错误:
error: no match for call to ‘(std::_Bind<void (*(std::_Placeholder<1>, int))
(int, int)>) (int)’
为什么程序无法编译?
我也无法从C++ Reference编译示例程序。