If I have a base class:
class Base
{
public:
virtual void Test()=0;
};
and, in a dynamically loaded module (.so/.dll), I implemented a class derived from this:
class SomethingFromBase : Base
{
...
};
and, the user, once this library is loaded, asks to create an instance of SomethingFromBase (let's say we get the name from cin.), and, we have no knowledge of SomethingFromBase (i.e, no way to just do if(inputstr == "SomethingFrombase") { ... } is there any way to create an instance of SomethingFromBase?
I'm fairly certain this is impossible in (standard) C++, but, I'm always hoping SO will surprise me!
If this is possible with the addition of some library, I'd still like to know about it. Thanks!
Edit: See cdhowie's answer. Guides to implementing this technique: http://www.linuxjournal.com/article/3687?page=0,1 http://www.abstraction.net/ViewArticle.aspx?articleID=67