title: C++ Is it possible to have a generic function pointer?
body: <p>In C++ is it possible to make some sort of generic function pointer that points to any function that returns a pointer to some type and takes no arguments?</p>
  
  <p>Eg, one type of pointer that can point to both of the following:</p>
  
  <pre><code>int* funcInt(){
      int* i = new int;
      *i = 5;
      return i;
  }
  
  char* funcChar(){
      char* c = new char;
      *c = 'a';
      return c;
  }
  </code></pre>
  
  <p>Obviously the below is valid:</p>
  
  <pre><code>int* (*funcPointerA)() = funcInt;
  char* (*funcPointerB)() = funcChar;
  </code></pre>
  
  <p>But is it possible to do something like the following (it gives a compile error at the moment):</p>
  
  <pre><code>void* (*funcPointerC)() = funcInt;
  void* (*funcPointerD)() = funcChar;
  </code></pre>
  
  <p>Currently the above code gives the following error:</p>
  
  <pre><code>error: invalid conversion from 'int* (*)()' to 'void* (*)()'
  error: invalid conversion from 'char* (*)()' to 'void* (*)()'
  </code></pre>
  
  <p>Is there any way to cast the  funcPointerA and B to C and D? </p>
  
  <p>This is so pointers to both types of functions (and others that return a pointer to some type while taking no arguments) can be stored together in a single vector.</p>