So I'm getting an error and I'm not sure why. I figured I would throw it out there to see if anyone can help me. I have a couple of classes. I want to use an instance of one class as a static data member in another, here's my code:
class MyObject
{
private:
int id;
string name;
static Pool pool;
MyObject (int i, const string &nm );
MyObject(const MyObject &x) {}; // I'll declare the copy constructor and assignment operator here so as to dissallow the use of them
MyObject & operator =(const MyObject &x) {};
public:
static MyObject* create(int id, const string& name);
void* operatornew (size_t size);
voidoperatordelete (void *);
};
class Pool
{
private:
MyObject* pt;
public:
Pool(size_t elemSize, size_t blockSize = 5, bool traceFlag = false);
void* allocate();
void deallocate(void*);
~Pool ();
I'm trying to use a Pool object as a static data member of MyObject.
The error I'm getting is C2146 missing ';' before identifier 'pool'. I don't understand. Help?