void process(int boat) { ; }
const void(*sequence_A[])(int) = { process, process }; //ERROR
const void(**func_sequence)(int) = sequence_A;
(*func_sequence++)(7);
爲什麼不能編譯?我希望const引用數組,而不是數組的內容。函數指針的const數組befuddles
Error 1 error C2440: 'initializing' : cannot convert from 'void (__cdecl *)(int)' to 'const void (__cdecl *)(int)'
編輯:所以你們說它不存在。很公平。只是要清楚,我張貼的我想要的功能,這個比喻,但這是爲int而不是函數的師生比
//Compiles without error
int number1 = 7;
int number2 = 3;
const int* sequence_B[] = { &number1, &number2 };
const int** numbers = sequence_B;
int check = **numbers++; //value is 7
int chec2 = **numbers++; //value is 3
不幸的是沒有這樣的東西'const'陣列,除了在'常量數組的感'物品。 –