Created
May 20, 2010 08:25
-
-
Save szastupov/407338 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Foo { | |
virtual int bar() = 0; | |
}; | |
struct A : public Foo { | |
int bar() { return 1; } | |
}; | |
struct B : public Foo { | |
int bar() { return 2; } | |
}; | |
struct FooDescr { | |
const char *name; | |
FooDescr(const char *name) : name(name) {} | |
virtual Foo* create() = 0; | |
}; | |
template <class T> | |
struct FooDescrT : public FooDescr { | |
FooDescrT(const char *name) : FooDescr(name) {} | |
Foo* create() { return new T(); } | |
}; | |
FooDescr* fd[] = { new FooDescrT<A>("Adfsdf"), new FooDescrT<B>("dfsdf") }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment