If I have an interface and many classes that implement this interface, can I now pass as argument only the type of the class and not the object?
something like this:
Interface *creatClass(class : Interface){
return new class();
}
EDIT:
template <class T>
IFrame *creatClass(){
return new T();
}
void dfg(){
IFrame *lol = creatClass<Button>();
}
error C3206: 'creatClass' : invalid template argument for 'Dist_Frame', missing template argument list on class template 'Button'
PS. Button inherits IFrame
It’s called “Template“.
You’ll have to call it this way:
edited
You can also try this, to ensure you only create instances of
Interface:edit to your edit
I tried this test code:
Works exactly as expected. You must have some other coding errors in your class definitions. Debug it, it has nothing to do with your original question.