lundi 19 mars 2018

Can I get the current class type id from a static base method?

Is there anyway to get a type from a static base class method? For instance

class A
{
    static std::type_info getClassType
    {
        // What do I do here
    }
};

class B : public A
{

};

B instance;
auto my_type = instance.getClassType()

With C++'s lack of static variable overloading, I am having a hard time figuring out a way to determine class type across classes without doing a special virtual function in every child class which I am trying to avoid due to the sheer number.

Aucun commentaire:

Enregistrer un commentaire