I\'m creating a resource manager that takes in classes derived from the class Resource
. My problem is that typeid(..).name() returns the wrong name of the class. >
If you are using Qt library, you could use the metaobject to distinguish the resource instances.
class Resource : public QObject {
Q_OBJECT
}; // abstract
class Texture : public Resource {
Q_OBJECT
};
Resource *texture = new Texture();
Resource *resource = new Resource();
texture ->metaObject()->className(); // yields 'Texture'
resource ->metaObject()->className(); // yields 'Resource'