线程C++:没有可用于调用的匹配函数
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
BM.h
void search( char *txt, char *pat , string id);
BM.cpp
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);
相关文章:
- 如何用参数值调用函数(仅在运行时已知)
- 从python中调用C++函数并获取返回值
- 当使用通配符和null指针调用函数时,对输出的说明
- 从R调用C++函数并对其进行集成时出错
- 使用QTreeView,如何通过调用函数只突出显示特定的行/列
- 如何在qt中从另一个类调用函数
- 在 COUT 语句中使用 COUT 调用函数
- 如何从线程中的不同模块调用函数?
- C++从函数指针数组调用函数
- 当 A 在 for 循环中调用函数 B 时,如何计算函数 A 的空间复杂度?
- 如何在 C/C++ 中从外部库调用函数
- 如何使用运算符在同一行中多次调用函数
- 是否可以创建一个从不同类调用函数的线程?
- 无法为类成员调用函数
- 如何从另一个标头 c++ 调用函数
- C++有什么方法可以在既不调用函数模板也不提供其模板参数的情况下引用函数模板?
- 如何只允许在调用函数 B 后调用函数 A?
- 我可以这样调用函数吗?
- 如何在 c++ 的类中递归调用函数方法?
- 为什么在指向对象的迭代器上调用函数不允许我更改对象本身?