Reputation: 13929
I read this typedef line in a C++ book, but I couldn't resolve its meaning:
typedef Shape* (*CreateShapeCallBack)();
Now, CreateShapeCallBack stands for what, any idea? Thanks.
Upvotes: 2
Views: 202
Reputation: 265151
returntype (*functionpointer)(parameters, ...)
is a function pointer in c++
Upvotes: 1
Reputation: 4985
Pointer to a function returning a pointer to a Shape
instance (which is Shape*
) and taking void
as a param - no params.
Compare this with, for example typedef int (*function_pointer)(double);
- this is a pointer to a function that takes double
as a parameter and returns int
...
Upvotes: 2
Reputation: 1394
It defines CreateCallBack as a function pointer. The function haves no arguments and returns the Shape pointer.
Upvotes: 1
Reputation:
It's the type of a pointer to a function that returns a pointer to a Shape and takes no parameters. You could use it like this:
Shape * Func() {
// do stuff - return Shape pointer
}
...
CreateShapeCallBack p = Func;
Upvotes: 8