#include #include #include class Object { public: virtual size_t GetTypeHash()const noexcept=0; virtual const char *GetTypeName()const noexcept=0; }; template class Inherit:public BASE { public: static const size_t StaticHash()noexcept { return typeid(T).hash_code(); } virtual size_t GetTypeHash()const noexcept override { return T::StaticHash(); } static const char *StaticName()noexcept { return typeid(T).name(); } virtual const char *GetTypeName()const noexcept override { return T::StaticName(); } };//template class Inherit:public T class TestClass:public Inherit { }; class TestClassA:public Inherit { }; class TestClassB:public Inherit { }; template void out(const char *name,T *obj) { std::cout<GetTypeName()<<": "<GetTypeHash()<("ta",&ta); out("tb",&tb); return 0; }