【发布时间】:2014-12-08 15:55:05
【问题描述】:
我创建了一个寻路算法,我可以在其中设置启发式方法。 但我正在使用一个
function<int (Point2i origin, Point2i destiny)> heuristicFunc;
作为我的函数指针,我想用我的默认heristic初始化它。
所以:
Pathfind.h
class Pathfind{
private:
function<int (Point2i origin, Point2i destiny)> heuristicFunc;
int hMethod(Point2i origin, Point2i destiny);
public:
Pathfind();
}
路径查找.cpp
Pathfind::Pathfind(){
//1st try
this->heuristicFunc=&Pathfind::hMethod;
//2nd try
this->heuristicFunc=std::bind(&Pathfind::hMethod, this);
}
但它返回相同的错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/functional:1472:15:候选函数不可行:没有已知的来自'int的转换(Core::Pathfind ::*)(Point2i, Point2i)' 到 'const std::__1::function, sf::Point2)>' 第一个参数
为什么它试图从 int(Core::Pathfind::*) 转换?
谢谢。
【问题讨论】: