无法调用函数 [英] Cannot call a function

查看:116
本文介绍了无法调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有这个代码:



EcosiaSearcher.h

Hello,

I have this code :

EcosiaSearcher.h

template <typename T, typename M>
	list<T> WINAPI do_search(string research, string parameters, void (M::*parse)(char* , list<T> &));





EcosiaSearcher.cpp



EcosiaSearcher.cpp

template <typename T, typename M>
list<T> WINAPI EcosiaSearcher::do_search(string research, string parameters, void (M::*parse)(char*, list<T> &))
{
	...
	list<T> results;

	...

	parse((char*)r_buffer, results);

	...

	return results;
}

template list<EcosiaWebResult> WINAPI EcosiaSearcher::do_search(string research, string parameters, void (EcosiaWebHtmlParser::*parse)(char*, list<EcosiaWebResult> &));





我尝试调用这样的函数:





And i try to call the function like this :

return EcosiaSearcher::do_search<EcosiaWebResult>(research, parameters, _web_parser.parse);





这是我想指出的功能的签名:





Here is the signature of the function i want to point :

void WINAPI parse(char* sz_buffer, list<EcosiaWebResult> &ls);





它不起作用。我有这个错误:





It doesn't work. I have this error :

Severity	Code	Description	Project	File	Line	Suppression State
Error	C3867	'EcosiaWebHtmlParser::parse': non-standard syntax; use '&' to create a pointer to member	Ecosiana	d:\users\deckbsd\source\projects\ecosiana\ecosiana\ecosiawebsearcher.cpp	17	





提前感谢您的时间和答案:)



我的尝试:



我也尝试过:



返回EcosiaSearcher :: do_search< ecosiawebresult>(研究,参数,和EcosiaWebHtmlParser ::解析);



...



Thanks in advance for your time and answers :)

What I have tried:

I also tried :

return EcosiaSearcher::do_search<ecosiawebresult>(research, parameters, &EcosiaWebHtmlParser::parse);

...

推荐答案

这显然是编译器检测到的错误,它也会大声说出如何解决它。



错误C3867 后用Google搜索解释了语法的一些细节。



因为你的全局范围我的函数会使用:

It is clearly an error which the compiler detect and it yells also how to fix it.

Googling after the Error C3867 and there is explained some details to the syntax.

Because your function with global scopeI would use:
do_search(research, parameters, &parse);


全部谢谢你的回复:)



确切地说C ++不是C#我做得对:





Thanks all for your replies :)

Exactly C++ is not C# i did it correctly :


template <typename typename="" m="">
list<t> WINAPI EcosiaSearcher::do_search(string research, string parameters, string page, M& parser, void (M::*parse)(char*, list<t> &))

</t></t></typename>




(parser.*parse)((char*)r_buffer, results);







template list<ecosiavideoresult> WINAPI EcosiaSearcher::do_search(string research, string parameters, string page, EcosiaVideoHtmlParser &parser, void (EcosiaVideoHtmlParser::*parse)(char*, list<ecosiavideoresult> &));
</ecosiavideoresult></ecosiavideoresult>





和电话:





and the call :

return EcosiaSearcher::do_search<ecosiawebresult>(research, parameters, ECOSIA_SEARCH_PAGE, _web_parser, &EcosiaWebHtmlParser::parse);
</ecosiawebresult>





最好的问候,



best regards,


这篇关于无法调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆