- 论坛徽章:
- 0
|
本帖最后由 sytpb 于 2015-04-08 22:49 编辑
class TestClass1{
public:
TestClass1(int d):data(d)
{}
bool test()
{
return data>3;
}
private:
int data;
};
TestClass1 *t1 = new TestClass1(1);
TestClass1 *t2 = new TestClass1(2);
TestClass1 *t3 = new TestClass1(4);
TestClass1 *t4 = new TestClass1(5);
std::vector<TestClass1*> lpt;
lpt.push_back(t1);
lpt.push_back(t2);
lpt.push_back(t3);
lpt.push_back(t4);
std::vector<TestClass1*>::iterator it = std::find_if(lpt.begin(),lpt.end(),std::mem_fun(&TestClass1::test)); //出错此行
如果test 如下
bool test(int a)
{
return data>a;
}
std::vector<TestClass1*>::iterator it = std::find_if(lpt.begin(),lpt.end(),std::bind1st(std::mem_fun(&TestClass1::test),3));
也没试对。请指教!
第一个find_if 出错信息
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:859:13: No matching function for call to object of type 'std::__1::mem_fun1_t<bool, TestClass1, int>' |
|