Dear all,
I am looking through a c++ code and I have found a typedef statement that I do not understand. it is on line 6 of the code below. Does anybody knows what that means? I always thought that typedef allows you to give a different name to a variable type, but here something else seems to be going on.
thanks in advance.
The type-definition you see can be described as: "Let "CreateObjectFunc" be an alias for a pointer to a non-member function, that returns a "BaseClassType", and accepts no arguments.
Another way to do the same is to define typedef for the corresponding function.
typedef BaseClassType TFunc();
It looks like a function declaration except that it follows keyword typedef.
Here TFunc is not a real function declaration. Here TFunc names any function that has return type BaseClassType and has no parameters.
Later you can declare a pointer to such a function as for example