Reputation: 41
I'm practicing the reflection in C++, and the code is as follows:
typedef void* (*PTRCreateObject)(void);
class ClassFactory{
private:
map<string, PTRCreateObject>m_classMap;
ClassFactory(){};
public:
void* getClassByName(string className);
void registClass(string name, PTRCreateObject method);
static ClassFactory& getInstance();
};
Upvotes: 0
Views: 247
Reputation: 63957
It's a carryover from C.
void* (*)(void)
is a pointer to a function that takes no parameters.
void* (*)()
is a pointer to a function that takes unspecified parameters.
Both mean no parameters.
()
is idiomatic and (void)
was allowed for backwards compatibility.
Upvotes: 4
Reputation: 604
It is just another way of representing no parameters.
typedef void* (*PTRCreateObject)(void);
and
typedef void* (*PTRCreateObject)();
are both equivalent.
the return signature void*
is just returning a pointer to some unknown type.
Upvotes: 1