I have a class Phone, I want it, when created to add itself to a static collection of phones. So I have the collection:
static vector < class Phone* > instances;
And in the constructor I do this:
Phone::instances.push_back(this);
But the linker throws an unresolved external symbol, why is that? What am I doing wrong? I didn't find a similar question. Is it necessary to add the instance outside the constructor? Or do I have to have the collection on another class? Thank you very much.