#include using namespace MyNamespace; Derived::Derived(const Registration&) { prototypeList().push_back(this); } Base* Derived::make (std::string filename) { std::list::iterator it = prototypeList().begin(); for ( ; it!=prototypeList().end(); ++it ) { if ((*it)->isMine(filename)) (*it)->make(filename); } } Base* Derived::clone() { return new Derived; } bool Derived::isMine(std::string filename) { // ----- this is just an example. replace it as you see fit. int a = filename.find_last_of("."); if ( a == -1 ) return false; if (filename.compare(".img", a, 4)) return true; return false; // --------------------------------------------------------- } Derived::~Derived() {} // non-members namespace { Derived Prototype(Registration("Derived")); } MyNamespace::Derived* DerivedPrototype = &Prototype;