2-d array alternate of map
<p>Below is my code....</p>

<p>i had use an map here..instead of map i want to use 2-d array .
user will enter command code say 50 and corresponding function will be called that is registered like</p>

<pre><code>to_do_commands.registerCommand(50,get_status);
</code></pre>

<p>full code below </p>

<pre><code>#include "stdafx.h"
#include &lt;assert.h&gt; 
#include &lt;iostream&gt; 
#include &lt;map&gt; 
#include &lt;string&gt; 
 using namespace std;


void ping(void) 
{ 
  cout &lt;&lt; "ping command executed\n"; 
} 

void get_status()
{

cout&lt;&lt;"get status executed";
}

class ToDoCommands 
{ 
  public: 
    typedef void (*FunctionPtr)(); 
    typedef int Code; 

    void registerCommand(Code code,FunctionPtr); 
    void callFunction(Code); 

  private: 
    map&lt;Code,FunctionPtr&gt; func_map; 
}; 

void ToDoCommands::registerCommand(Code code,FunctionPtr func_ptr) 
{ 
  func_map[code] = func_ptr; 
} 

void ToDoCommands::callFunction(Code code) 
{ 
  assert(func_map.find(code)!=func_map.end()); 
  func_map[code](); 
} 

int main(int argc,char **argv) 
{ 
  ToDoCommands to_do_commands; 

 // to_do_commands.registerFunction(50,ping);
  to_do_commands.registerCommand(10,ping);
  to_do_commands.registerCommand(50,get_status);
  to_do_commands.callFunction(50); 

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