web123456

C++ new and array of function pointers

#include <iostream>

using namespace std;

   

   

void f(){

cout << "hello, world" << endl;

}

   

int main() {

void (*(*p)) () = new (void (*[7]) ());

for(int i = 0; i < 7; i++) {

p[i] = f;

}

   

for(int i = 0; i < 7; i++) {

(p[i])();

}

   

delete [] p;

   

        return 0;

}