我对std::thread
类的 Visual Studio 2012 实现有疑问。
Error C2248: "std::thread::thread": cannot access private member declared in class std::thread
c:\program files (x86)\microsoft visual studio 11.0\vc\include\xmemory0 line: 606
A.hpp:
class A{
public:
A();
~A();
private:
vector<thread> listOfThreads;
int numberOfProcessorCores;
int startUpWorkerThreads();
};
A.cpp:
int A::startUpWorkerThreads(){
if(numberOfProcessorCores <= 0) return 2; //Keine Angabe zur Anzahl der Prozessorkerne
if(listOfThreads.size() > 0) return 3; //Bereits initialisiertdefiniert
for(int i = 0; i < numberOfProcessorCores; i ++){
thread newThread(&TaskManagement::TaskManager::queueWorker);
listOfThreads.push_back(newThread);
}
return 0;
}
这是我的程序中使用线程类的部分。
有谁知道为什么会发生这个错误?