I tried to declare a memory pool in my class.
But the compiler shows some basic error like missing ‘)’ before ‘;’
or syntax error : ‘sizeof’
It works well if I used the pool as local variable but I really want to make it live with the class.
What’s wrong about my usage?
Here is the class, the MAX_OBJ is a const
class CData
{
public:
CData(void);
~CData(void);
private:
boost::pool m_Pool(sizeof(DWORD) * MAX_OBJ);
};
I don’t think it as anything to do with
boost::pool.But this line:
Should probably be:
And your constructor should then be:
You cannot construct members in the class declaration. You can just say: “My class has a member named
m_Poolwhose type isboost::pool.”You then specify in one or several constructor(s), how this member is initialized.