c++ reference to function pointer dynamically
<p>I have one application in which following task are to be done </p>

<pre><code>1.) UI application will send command code (integer value).
2.) DLL interface(in c++) will get that integer value and execute corresponding command function.
</code></pre>

<p>commands name and command code are maintained as</p>

<pre><code>#define PING 50
</code></pre>

<p>there will be 500 commands and applying SWITCH CASE will not sound good. so i decided to implement function pointer in my code as below</p>

<pre><code>   #include "stdafx.h"

    #include&lt;iostream&gt;
    #define PING 20

    using namespace std;
    //extern const int PING = 10; 
    void ping()
    { 
                    cout&lt;&lt;"ping command executed";
    }


    void get_status(void)
    {


    cout&lt;&lt;"Get_status called"&lt;&lt;endl;

    }

    class ToDoCommands
    {
            public:
                void getCommand( void (*CommandToCall)() );                         
    };



    void ToDoCommands::getCommand( void (*CommandToCall)())
    {


        void (*CommandToCall1)();

        CommandToCall1  = CommandToCall;

        CommandToCall1();

    }

    int main()
    {
            int code;
            ToDoCommands obj;
            cout&lt;&lt;"enter command code";
            cin&gt;&gt;code;  // if UI send 50 then Ping function get executed as #define PING 50

            obj.getCommand(ping);   // here m passing ping manually..
            //obj.getCommand(get_status);

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

<p>how can i pass  command name corresponding to command code in</p>

<pre><code>obj.getCommand(ping); 
</code></pre>
