I have an abstract class on which I would like to include as a static variable an array of pointers for that same class. This array would be later used by the derived classes.
class Base {
public:
virtual int someValue() = 0;
static Base* Bases[100];
void Startup() {
Bases[2] = this; // just a test
};
};
class Derived : public Base {
public:
virtual int someValue() {return 10};
};
Yet, when compiling, I get the following error: Undefined symbols for architecture i386 "Bases", referenced from: Base::Startup().
How can I achieve this result?
statichave to be defined outside the class.std::vector. It's a lot less work.