title: How to use Function Pointer as a parameter in a Class
body: <p>I am trying to construct a class that is essentially a queue of futures that are all handled asynchronously and eventually all stored when main wants to get their values. I am having trouble creating the function parameters that will accept these functions and their arguments in order to create an async operation that is then pushed in to the queue of futures. The areas in question are the call constructor and the member function <code>add()</code>.  Here is what I have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;queue&gt;
  #include &lt;future&gt;
  #include &lt;thread&gt;
  
  using namespace std;
  using longInt = unsigned long long int;
  
  //prototypes
  longInt isPrime(longInt);
  
  template &lt;typename return_type&gt;
  class TaskQueue {
  private:
      queue&lt;future&lt;return_type&gt;&gt; tasks;
  public:
      //return a copy of the queue
      queue&lt;future&lt;return_type&gt;&gt; copy() const {
          return tasks;
      }
  
  
      //default constructor
      //does nothing, waits for input
      TaskQueue() {
          //do nothing
      }
  
      //call constructors
      //adds task to queue
      TaskQueue(return_type (*func)(), Args&amp;&amp; ... args) {
          tasks.push(new async(func, args));
      }
  
      //copy constructor
      //copies another queue to this one
      TaskQueue(const queue&lt;future&lt;return_type&gt;&gt; &amp; in) {
          tasks = in.copy();
      }
  
      //setter and getter functions
  
      //inserts a new task into the queue
      void add(return_type(*func)(), Args&amp;&amp; ... args) {
          tasks.push(new aync(in, args));
      }
  
      //returns true if the task at the top of the queue is ready
      bool valid() {
          return tasks.front().valid();
      }
  
      //gets the value, if the value is not ready, waits for it to be ready
      //pops the top task after getting it
      return_type get() {
          return_type temp = tasks.top().get();
  
          tasks.pop();
  
          return temp;
      }
  
      //waits for the value of the top of the queue to become ready
      void wait() {
          tasks.top().wait();
      }
  
  
  };
  
  int main() {
      TaskQueue&lt;longInt&gt; checkPrimes;
  
      checkPrimes.add(isPrime, 5);
  
      longInt test = checkPrimes.get();
  
      cout &lt;&lt; test &lt;&lt; endl;
  
  }
  
  //returns the number if it is prime or 0 if it is not
  longInt isPrime(longInt n) {
      if (n &lt;= 3) {
          if (n &gt; 1) {
              return n;
          }
          return 0;
      }
  
      if (n % 2 == 0 || n % 3 == 0) {
          return 0;
      }
  
      for (unsigned short i = 5; i * i &lt;= n; i += 6) {
          if (n % i == 0 || n % (i + 2) == 0) {
              return 0;
          }
      }
  
      return n;
  }
  </code></pre>