取れません。g++ コンパイラを使用します。
コード:
#include <iostream>
using namespace std;
typedef void (* FPTR) ();
class Test
{
void f1()
{
cout << "Do nothing 1" << endl;
}
void f2()
{
cout << "Do nothing 2" << endl;
}
static FPTR const fa[];
};
FPTR const Test::fa[] = {f1, f2};
エラー:
test.cpp:22: error: argument of type ‘void (Test::)()’ does not match ‘void (* const)()’
test.cpp:22: error: argument of type ‘void (Test::)()’ does not match ‘void (* const)()’
関数ポインタの定数配列を取得したいだけなので、
fa[0] = f2;
「読み取り専用メンバーの変更 Test::fa」のようなエラーが発生します