This question has already been answered:

How to set a type alias указатель на функцию with typedef ?

Reported as a duplicate by members of Pavel Parshin , zRrr , VenZell , D-side , user194374 Jun 8 '16 at 14:42 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 2
    in my opinion, this: typedef rettype (* name) (argtype arg1, ...); - nick_n_a
  • @nick_n_a argument names are not needed. - αλεχολυτ
  • @alexolut, but their presence is not a mistake? - Grundy
  • @Grundy is not. But I do not know the situations when they could be used. You know? - αλεχολυτ
  • one
    @alexolut, maybe some IDE may suggest them somehow, as an application option :) - Grundy

1 answer 1

Something like this, with the right number of arguments and the type of result.

 typedef bool (*t_func)(int,int); bool isEqual(int x, int y) { return x == y; } t_func my_func = &isEqual; 

call: (* my_func) (7, 3);

  • one
    A dereferencing call is optional. And the returned types do not match. - αλεχολυτ
  • I think the real answer is the page from help typeex syntax. This is so, a concise answer. - nick_n_a