class c
{
public:
int id;
boost::thread_group thd;
c(int id) : id(id) {}
void operator()()
{
thd.create_thread(c(1));
cout << id << endl;
}
};
我創建了類c。每個類對象創建線程以處理工作。錯誤C2248:然而,當我編譯這個C++ Boost,使用類中的thread_group
我得到這個奇怪的消息「提振:: thread_group :: thread_group」:不能訪問類「的boost :: thread_group」
除了宣佈私有成員,只是假設是沒有遞歸調用問題。
但我必須創建具有成員變量和函數的類對象。所以我不能把線程作爲一個單一的功能。無論如何,像我上面所做的那樣創建類對象? – Jaebum 2011-12-16 06:55:40