我正在使用为我正在做的练习预定义的头文件中的函数。我主要有;
defineClickListener(clickAction, graph);
clickAction 是我制作的一个函数,在 main 上方有一个原型,而 graph 是 pathfindergraph 类的一个实例。在包含的 pathfindergraphics 标题中,它说;
/**
* Function: defineClickListener
* Usage: defineClickListener(clickFn);
* defineClickListener(clickFn, data);
* ------------------------------------------
* Designates a function that will be called whenever the user
* clicks the mouse in the graphics window. If a click listener
* has been specified by the program, the event loop will invoke
*
* clickFn(pt)
*
* or
*
* clickFn(pt, data)
*
* depending on whether the data parameter is supplied. In either
* case, pt is the GPoint at which the click occurred and data
* is a parameter of any type appropriate to the application. The
* data parameter is passed by reference, so that the click function
* can modify the program state.
*/
void defineClickListener(void (*actionFn)(const GPoint& pt));
template <typename ClientType>
void defineClickListener(void (*actionFn)(const GPoint& pt, ClientType & data), ClientType & data);
据我所见,我正确使用了defineClickListener,但我收到一条错误消息,提示“没有调用'defineClickListener'的匹配函数”。不知道我做错了什么 - 有什么想法吗?