Need some help with initializing an array of pointers to member functions
<p>I'm very new to programming &amp; came across a program in a book i'm reading.I get a compile error in it.</p>

<p>The error says "variable-sized object 'ptrFunc' may not be initialized".(it points to the end of the array)</p>

<p>Please advise,what is wrong in it.Thanks in advance.</p>

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

using namespace std;

class cDog
{
    public:
            void speak() const
            {
                cout&lt;&lt;"\nWoof Woof!!";
            }
            void move() const
            {
                cout&lt;&lt;"\nWalking to heel...";
            }
            void eat() const
            {
                cout&lt;&lt;"\nGobbling food...";
            }
            void growl() const
            {
                cout&lt;&lt;"\nGrrrgh...";
            }
            void whimper() const
            {
                cout&lt;&lt;"\nWhinig noises...";
            }
            void rollOver() const
            {
                cout&lt;&lt;"\nRolling over...";
            }
            void playDead() const
            {
                cout&lt;&lt;"\nIs this the end of little Ceaser?";
            }
};

int printMenu();

int main()
{
    int selection = 0;
    bool quit = 0;
    int noOfFunc = 7;
    void (cDog::*ptrFunc[noOfFunc])() const = {

    &amp;cDog::eat,
    &amp;cDog::growl,
    &amp;cDog::move,
    &amp;cDog::playDead,
    &amp;cDog::rollOver,
    &amp;cDog::speak,
    &amp;cDog::whimper
    };

    while(!quit)
    {
        selection = printMenu();

        if(selection == 8)
        {
            cout&lt;&lt;"\nExiting program.";
            break;
        }
        else
        {
            cDog *ptrDog = new cDog;
            (ptrDog-&gt;*ptrFunc[selection-1])();
            delete ptrDog;
        }
    }
    cout&lt;&lt;endl;

    return 0;
}

int printMenu()
{
    int sel = 0;

    cout&lt;&lt;"\n\t\tMenu";
    cout&lt;&lt;"\n\n1. Eat";
    cout&lt;&lt;"\n2. Growl";
    cout&lt;&lt;"\n3. Move";
    cout&lt;&lt;"\n4. Play dead";
    cout&lt;&lt;"\n5. Roll over";
    cout&lt;&lt;"\n6. Speak";
    cout&lt;&lt;"\n7. Whimper";
    cout&lt;&lt;"\n8. Quit";
    cout&lt;&lt;"\n\n\tEnter your selection : ";
    cin&gt;&gt;sel;

    return sel;
}
</code></pre>
