The more I think about it, the more I have a feeling I have to change my design but here's the problem, anyway.

I have a templated class. This class has a static class member variable, which is a templated stl_container. Then there is a class derived from this one that tries to call this member variable in a source file, but results in a linker error. Here's some simplified code:

Code:
// in a header file
template <typename T>
class A {
static stl_container<T*>* container;
};

class B : public A<MyClass> {
void do_something();
};

//in a source file
//memory allocation for "container" is in different source file

void B::do_something() {
do_something_to(container);
}
This gives me a linker error saying it can't find "container" being called from "do_something". Which, if I think about it, makes sense because there is no other object file for it to link from.

So I can think of one solution which would be to dump the definition of "do_something" into the class body so it doesn't have to resolve the linking error. But I've got other non-class functions that have to access "container" so that's a no go.

So how do you declare, allocate and use a templated static class variable? Is it possible?

I need this thing to be static because "class A" is a actually a node in a graph structure that links to other nodes in the graph and info on the overall graph (kept in the container) can be updated by any node.