1

Suppose I want to declare an array of functions, and try the following

int (*funcs)(int, int)[10];

But turns out that the following declaration stands for an function returning an array, which does not compile.

How can I declare an array of functions properly?

Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
Karen Baghdasaryan
  • 2,407
  • 6
  • 24

2 Answers2

3

Strictly speaking you may not declare an array of functions. You may declare an array of function pointers.

It seems you mean

int (*funcs[10])(int, int);

Another way is to introduce a using declaration (or a typedef declaration) like for example

using FP = int( * )( int, int );

FP funcs[10];

or

using FUNC = int ( int, int );

FUNC * funcs[10];
Vlad from Moscow
  • 301,070
  • 26
  • 186
  • 335
1

It should be

int (*funcs[10])(int, int);

Or ask help of using (or typedef).

using fp = int (*) (int, int);
fp funcs[10];
songyuanyao
  • 169,198
  • 16
  • 310
  • 405