![](/img/trans.png)
[英]C++ Multithreading Error : no matching function for call to 'std::thread::thread(<unresolved overloaded function type>
[英]Thread C++: no matching function for call to
我是c ++的新手,我想利用线程从主类调用BM类方法。我有main.cpp,BM.h和BM.cpp文件
我在main.cpp中的部分代码
string id = res->getString("nct_id");
char txt[temp_size];
char pat[5];
BM bm ;
thread Sam(&BM::search,&bm, txt, pat ,id); // use thread calls class method
体重
void search( char *txt, char *pat , string id);
压缩文件
void BM::search( char *txt, char *pat ,string id)
我有错误:
No matching function for call to
'std::thread::thread(void (BM::*)(char*, char*, std::string), BM*, char [(((sizetype)(((ssizetype)temp_size) + -1)) + 1)], char [5], std::string&)'
请帮我
谢谢
这是因为您使用的是非标准语言扩展,即可变长度数组(VLA)。 这些数组不适用于模板。 建议抛弃所有字符数组和所有VLA,并始终使用std:string和std :: vector。
如果不能,请使用以下简单的解决方法:
thread Sam(&BM::search,&bm, &txt[0], pat ,id);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.