Can someone please explain the Base*(*)() for me as in:
typedef std::map<std::string, Base*(*)()> map_type;
And how would one return it from a function?
I presume it is a function pointer, a Base* is returned, but what is this (*).
I found this in the following SO post Is there a way to instantiate objects from a string holding their class name?
Thanks
Base* (*)()is a type: pointer to function returningBase*. The*means that it is a pointer and the()are used to to override the precedence to ensure that the pointer applies to the function itself and not the return type.You can return it from a function by returning the name of a function of the appropriate type.
E.g.