Defining and initializing a static const array of non-const function pointers in C++
<p>Can't get it.
Using g++ compiler.</p>

<p>Code:</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

typedef void (* FPTR) ();

class Test
{
    void f1()
    {
        cout &lt;&lt; "Do nothing 1" &lt;&lt; endl;
    }

    void f2()
    {
        cout &lt;&lt; "Do nothing 2" &lt;&lt; endl;
    }

    static FPTR const fa[];
};

FPTR const Test::fa[] = {f1, f2};
</code></pre>

<p>Error:</p>

<pre><code>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)()’
</code></pre>

<p>I just want to obtain constant array of function pointers, so</p>

<pre><code>fa[0] = f2;
</code></pre>

<p>will cause an error like 'modifying read-only member Test::fa'</p>
