I am developing a big hierarchy of classes for a framework that will require quite a lot of type casting when it gets done.
My question is, how stupid of an idea is to put in a static member that uses an enum to store all the object types in the hierarchy. Having the member static for every class will not increase the instanced object sizes, and will give a (potentially) faster way to determined the type of an object during runtime than dynamic_cast.
At least that’s the basic idea. How adequate would this approach be, and are there any potential flaws?
I don’t know how you were gonna determine the type of each object from a static variable that is shared between the objects. Unless you have some virtual function that you override for each class, but then you don’t need the static variable at all, just do something like this:
Not the fastest solution, but several magnitudes faster than
dynamic_castortypeid.