title: C++ Array of Functions
body: <p>I'm trying to deal with an array of functions, however when I assign the functions to the array (in the class's default constructor) I am greeted with the error message:</p>
  
  <blockquote>
    <p>"void (GameObject::*)()" cannot be used to initialize an entity of type "AlarmFunction""</p>
  </blockquote>
  
  <p>All code dealing with this is as follows, this is all in the header file:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;Windows.h&gt;
  
  typedef int (*AlarmFunction) ();
  
  class GameObject
  {
  protected:
  GameObject()
  {
      AlarmFunction alarmF[12] =
      {
          AlarmEvent1,
          AlarmEvent2,
          AlarmEvent3,
          AlarmEvent4,
          AlarmEvent5,
          AlarmEvent6,
          AlarmEvent7,
          AlarmEvent8,
          AlarmEvent9,
          AlarmEvent10,
          AlarmEvent11,
          AlarmEvent12
      };
  }
  //private default constructor
  ~GameObject();
  int instance_id;
  int object_id;
  int alarm[12];
  void AlarmEvent1();
  void AlarmEvent2();
  void AlarmEvent3();
  void AlarmEvent4();
  void AlarmEvent5();
  void AlarmEvent6();
  void AlarmEvent7();
  void AlarmEvent8();
  void AlarmEvent9();
  void AlarmEvent10();
  void AlarmEvent11();
  void AlarmEvent12();
  AlarmFunction alarmF[12];
  
  public:
  void AlarmTick()
  {
      for (int i=0;i&lt;=11;i++)
      {
          if (alarm[i] &gt; -1)
          {
              alarm[i]--;
          }
          else
          {
              if (alarm[i] == 0)
              {
                  alarmF[i]();
              }
          }
      }
  }
  </code></pre>
  
  <p>I can't find much on the web about this error or indeed how to fix it, and would be grateful if anyone could shed some light on the error for me.</p>