Hello,
I really don't understand the simplest thing at the moment. I have a static
array of pointers to a class . How do we initialize it?
class classA
{
public:
int x1;
};
class classB
{
public:
void foo() { cout<< m_ptr[0]->x1; }
static classA* m_ptr[4];
};
classA* classB::m_ptr[0]=0; // This is not correct !!!
classA* classB::m_ptr[1]=0; // This is not correct !!!
classA* classB::m_ptr[2]=0; // This is not correct !!!
classA* classB::m_ptr[3]=0; // This is not correct !!!
int main()
{
classB* ptr = new classB;
ptr->foo();
return 0;
}
Any idea? If "m_ptr" was not an array of pointers I would had initialize it
like this: "classA* classB::m_ptr=0;"
What about arrays now?