2

I've got this:

void (**funcs)();
funcs = new void (*)()[n];

And am getting errors about void, parenthesis, etc. What is the right syntax?

I know about vectors but I just want to know how it would be done this way.

4
  • Or better use std::function with std::vector. Commented Feb 7, 2013 at 3:44
  • 1
    @jogojapan I've seen that question just before asking this actually--it's just missing the second part, eg. where [n] is (or at least as far as I can decipher). Commented Feb 7, 2013 at 3:51
  • 1
    You want funcs = new (void (*[3])()); Commented Feb 7, 2013 at 3:54
  • Curious: why don't you want to use a typedef? Commented Feb 7, 2013 at 4:27

1 Answer 1

4

If you insist on using raw pointers for some reason, or you're just curious, the syntax is:

void (**funcs)() = new (void(*[100])());


But seriously, just use std::vector:

std::vector<void(*)()> vec;
Sign up to request clarification or add additional context in comments.

2 Comments

I don't think this is answering the OP's question.
I do have a reason, but thank you for giving the alternate method too for when I'll feel less masochistic.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.