Classes (and types in general) in C++ are not first-class values and therefore cannot be passed around or stored.
For classes you can theoretically use typeid
but most often I found more useful just having strings returned by a virtual function in instances and a registry to implement a "virtual constructor" pattern.
struct Base
{
virtual const char *class_name() = 0;
...
};
struct MyClass : public(Base)
{
virtual const char *class_name() { return "MyClass"; }
...
}
std::map<std::string, Base *(*)()> instance_builders;