Firstly, I've got functions like this.
void func1();
void func2();
void func3();
Then I create my typedef for the array:
void (*FP)();
If I write a normal array of function pointers, it should be something like this:
FP array[3] = {&func1, &func2, &func3};
I want to make it a constant array, using const before "FP", but I've got this error messages:
error: cannot convert 'void ( * )()' to 'void ( * const)()' inialization
PD: Sorry my bad English.
EDIT:
x.h
typedef void (*FP)();
class x
{
private:
int number;
void func1();
void func2();
void func3();
static const FP array[3];
}
x.cpp
const FP x::array[3] = {&x::func1, &x::func2, &x::func3};
My code is more large and complex, this is a summary
Did you miss
typedef
beforevoid
?Following works on my compiler.
EDIT
(after seeing your edits)x.h
Which compiler are you using? This works on VS2005.
If you want the array itself to be const:
without
typedef
: