"John Harrison" <> wrote in message
news:c6ahbn$9ppkf$1@ID-> "Boris Sargos" <> wrote in
message
> > I need to write a function that returns a pointer on a function. Is it
> > possible, and which is the syntax ?
> Trying to do that without using a typedef is a real test of your
> understanding of type declarations. The easy way is with a typedef
Without typedef I think this is it:
void (*some_function())();
This is a function some_function taking no arguments and returning a pointer
to a function taking no arguments and returning a void. It's similar to a
function taking a reference to an array of elements. But of course, what
you have below is cleaner:
> typedef void (*FUNC_PTR)(void); // or whatever
>
> FUNC_PTR some_function()
> {
> ...
> }
>
> It is however impossible to define a function that returns a pointer to
> itself, that would mean an infinite recursion in the type of that
function.
This makes sense, because of
typedef FUNC_PTR (*FUNC_PTR)(void); // or whatever
But what about
void (*)(*some_function())();
Just guessing. Could be wrong.
|