Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ returning an array of void pointers [duplicate]

Possible Duplicate:
C++ return array from function

I am trying to declare a function that returns an array of void pointers. I have the following code:

void *[] get_functions();

However I get the compilation error: expected unqualified-id before '[' token

Is what I'm trying to do valid, and if so what is my syntax error?

EDIT In reply to some of the comments, I am trying to return an array (which now will probably be a vector) of functions, which I can then randomly select one and call it. What would you suggest instead of void *?

EDIT 2 The type of functions returned will have a fixed signature (not decided yet), Let's for arguments sake say the signature will be int f(int i, int j) what would the return of my get_functions function look like, or will vector<void*> still be appropriate?

like image 930
Aly Avatar asked Jun 20 '26 08:06

Aly


1 Answers

C++ doesn't allow a function to return an array. You should probably return a vector instead:

std::vector<void *> get_functions();
like image 179
Jerry Coffin Avatar answered Jun 23 '26 02:06

Jerry Coffin