Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Function pointer syntax

30 views
Skip to first unread message

Paul

unread,
Jun 13, 2015, 4:18:05 PM6/13/15
to
I read that A c3(A()); creates a function declaration for a function c3 that returns an A and that takes a function pointer to a function returning an object of type A

I thought pointers had to be indicated by *. Wouldn't the above function declaration be written A c3(A (*()));

Thank You,

Paul

Ben Bacarisse

unread,
Jun 13, 2015, 4:48:07 PM6/13/15
to
Paul <peps...@gmail.com> writes:

> I read that A c3(A()); creates a function declaration for a function
> c3 that returns an A and that takes a function pointer to a function
> returning an object of type A
>
> I thought pointers had to be indicated by *.

It's a good idea to be explicit but it's not necessary:

8.3.5 Functions

5. [...] After determining the type of each parameter, any parameter
of type "array of T" or "function returning T" is adjusted to be
"pointer to T" or "pointer to function returning T,"
respectively. [...]

> Wouldn't the above function declaration be written A c3(A (*()));

No, it would be A c3(A (*)()); if you wanted to show the pointer
explicitly.

--
Ben.

Paul

unread,
Jun 15, 2015, 1:28:07 PM6/15/15
to
Ok. It's clearer now. Thanks a lot.

Paul
0 new messages