is there a possibility to get the name of a class from one of its base classes without much effort ? would be nice if it'd be somewhat standardized stuff
I am not sure quite what you mean, but you could have a private variable that is modified to the class's name in the class's constructor. You could also make a global constant value and just set the string to use it.
dynamic cast would cast it, yes, but I want the name of it.
I could of course create a virtual function returning the name, or a member variable being updated. that could of course be optimized by some preprocessor stuff to have less to write. but that's all stuff i'd call too much effort
dynamic cast would cast it, yes, but I want the name of it.
I could of course create a virtual function returning the name, or a member variable being updated. that could of course be optimized by some preprocessor stuff to have less to write. but that's all stuff i'd call too much effort
Well...with dynamic_cast you can see if class X is from type Y. If its not it will return NULL.
Although I'm not sure if it will work on base classes...
I think the best way is(like sfx1999 said) to make a way to 'identify' each class, since dynamic_cast isn't very efficient I believe.
I just realized something. My method might not work either. The main class's constructor might override the derived one's. You would need a hack to check if the value was set.