Possible Duplicate:
minimal reflection in C++
Basically I have class name stored in char * , how Do i create instance of that class.
Following is what I was thinking. It works when I pass Test as template parameter which is fine, but if I try something like this Test *t = CreateType<ptr> it will not work.
Is there any way to make this work.
class Test{
public:
    Test() {
    }
    ~Test() {
    }
};
template <typename T> 
T* CreateType() {
    return new T;
}
int main ( int argc, char **argv) {
    char *ptr = "Test";
    Test *T = CreateType<Test>();
    return 0;
}
 
     
     
    