Error C3867 Multithreading C++
Error C3867 Multithreading C++
我试图创建多个线程来处理点击任务。现在Visual Studio 2015不显示语法错误,但在编译时,我得到错误
C3867 'action::Chrome::click': non-standard syntax; use '&' to create a pointer to member
int main()
{
std::unique_ptr<action::Chrome>chrome(new action::Chrome());
const std::vector<uint_16>xLocation = { 1155, 1165, 1205, 1245, 1285 };
std::vector<uint_16>yLocation;
//Fill yLocation
//Yada yada, other code
std::thread task[6];
for(uint_8 i = 0; i < 6; i++)task[i] = std::thread((chrome->click, xLocation, yLocation[i]));
for(uint_8 i = 0; i < 6; i++)task[i].join();
}
您将获得指向&action::Chrome::click
的成员函数的指针,而不是chrome->click
。
如果传递指向成员函数的指针,则第二个形参应该是调用该函数的对象。
你的参数列表也有问题;额外的括号意味着您只将yLocation[i]
传递给线程的构造函数。
std::thread(&action::Chrome::click, chrome, xLocation, yLocation[i]);
相关文章:
- Multithreading unordered_map
- boost.python c++ multithreading
- Multithreading Visual Studio C++
- C++ multithreading
- Linux gnu++11,在运行时获取"Enable multithreading to use std::thread: Operation not permitted"
- Nginx + fastcgi multithreading
- Multithreading, OpenMP,C
- Error C3867 Multithreading C++
- gSOAP Multithreading
- QuantLib Multithreading/Concurrecy
- MFC multithreading: AfxBeginThread vs Boost.Thread?
- openMP multithreading c++
- c/c++ epoll multithreading
- OpenCV C++ Multithreading