我有以下類定義,由於某些原因,我無法在類定義本身內定義線程池。它說:語法錯誤:標識符'numberofpoolthreads'我試着直接在類中定義它,但它給了我相同的語法錯誤,有誰知道這是爲什麼?無法解釋的語法錯誤定義線程池內部類定義
#include "stdafx.h"
#include <boost/threadpool.hpp>
#include <boost/threadpool/pool.hpp>
#include <boost/threadpool/detail/pool_core.hpp>
typedef boost::threadpool::fifo_pool resolverpool;
class ResolverThreadPoolManager
{
public:
ResolverThreadPoolManager::ResolverThreadPoolManager(int numberofpoolthreads);
ResolverThreadPoolManager::~ResolverThreadPoolManager();
resolverpool p(numberofpoolthreads);
private:
int numberofpoolthreads;
};
通常你像這樣初始化線程池:boost :: threadpool:fifo_pool pool(5),其中5是線程池線程的數量。我想把這個數字保存在一個變量中,那麼我該怎麼做呢? – 2010-10-18 12:05:36
@Tony:查看我答案的更新。 – 2010-10-18 12:09:35