C++ static virtual members?

No, there’s no way to do it, since what would happen when you called Object::GetTypeInformation()? It can’t know which derived class version to call since there’s no object associated with it.

You’ll have to make it a non-static virtual function to work properly; if you also want to be able to call a specific derived class’s version non-virtually without an object instance, you’ll have to provide a second redunduant static non-virtual version as well.

Leave a Comment