<分区>
我想了解 C++ 中的线程,但我不知道如何解决这个问题。
我想调用两个线程来运行名为“createS”的函数,但出现此错误:
error: invalid use of non-static member function
我读过关于这个主题的其他问题,但我真的不明白如何让我的代码工作。
有人可以向我解释我做错了什么并尝试帮助我找到解决方案吗?
test_class.cpp
void test_class::generateS(){
map1=new multimap<double,vector<int>>;
map2=new multimap<double,vector<int>>;
thread thread_1( createS, 0, nCells/2, map1 );
thread thread_2( createS, nCells/2, nCells, map2);
thread_1.join();
thread_2.join();
}
void test_class::createS(int startP, int endP, Costs *mapPointer){
//i do some stuff
}
test_class.h
void createS(int start, int end, Costs *mapPointer);
void generateS();