views:

159

answers:

1

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);
};
+2  A: 

I don't think it as anything to do with boost::pool.

But this line:

boost::pool m_Pool(sizeof(DWORD) * MAX_OBJ);

Should probably be:

boost::pool m_Pool;

And your constructor should then be:

CData::CData() :
  m_Pool(sizeof(DWORD) * MAX_OBJ)
{
}

You cannot construct members in the class declaration. You can just say: "My class has a member named m_Pool whose type is boost::pool."

You then specify in one or several constructor(s), how this member is initialized.

ereOn
Thanks, what a basic error I made... :(
Judarkness
@Judarkness: You're welcome. I just wasted 10 minutes to find a missing `;` in my own code so I guess we all do basic errors at some point ;)
ereOn