tags:

views:

103

answers:

4

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.

+8  A: 

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;
anon
+1  A: 

It defines CreateCallBack as a function pointer. The function haves no arguments and returns the Shape pointer.

VDVLeon
+2  A: 

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...

Kotti
+1  A: 
returntype (*functionpointer)(parameters, ...)

is a function pointer in c++

knittl