title: How can I create a struct with a vTable or array of function pointers in C?
body: <p>I am having a problem with declaring a struct with an array of function pointers (vTable) in C because if I declare the function pointer first <strong>and a parameter needs to be a self-referencial "this" pointer to itself</strong>, the struct hasn't yet been declared. If I declare the function pointer AFTER the struct, then the function type hasn't been declared so the compiler complains when I set up the struct:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  typedef int (*math_operation) (struct _MyClass *this,int a, int b);
  typedef struct _MyClass{
      int number;
      char name[50];
      math_operation *vTable[50];
  } MyClass;
  int main(void)
  {
      MyClass *test;
      return(EXIT_SUCCESS);
  }
  </code></pre>
  
  <p>What is the proper way to create an array of function pointer which have a "this" pointer to the parent struct?</p>