I already figured out to use polymorphism and have the list store the pointer to the baseClass, but after successfully placing it there, I would like to know what class the object was originally. I am using templates for the classes, and wanted to have an another field which would be an enum of basic types.
Now the question: is there a way to check (during runtime or during compilation) an
(if T == int)
field = INT
I though maybe something with the preprocessor but I’m not familiar with that.
You can use operator
typeid.For example, if
Tis a pointer to a base class:(It is somewhat unclear for me why you speak about
intin connection with polymorphism.intcannot be derived from.)