title: Assign a function pointer using template method?
body: <p>consider the Utility class below:  </p>
  
  <p>It will contain lots of factory methods with same signature <code>int function(int a, int b);</code></p>
  
  <p><strong>Utility.h</strong></p>
  
  <pre><code>class Utility
  {
   public:
  
      template&lt;typename T, typename A, typename B&gt; 
      static int get_function(T% function, int% number)
      {
          function = (T) add;
          number = 10;
          return 0;
      }
  
      static int add (int a, int b) {
          return a+b;
      }
  };
  </code></pre>
  
  <p>this contains a template method (get_function()) to assign Function pointers from factory methods available in <code>Utility</code> class.</p>
  
  <p><strong>Main.cpp</strong></p>
  
  <pre><code>typedef int (__stdcall *FP) (int a, int b);
  
  
  ref class FPClass
  {    
      public:
          static FP fp;
  
          static int number;
  
          static void apply_function()
          {
              Utility::get_function&lt;FP, int, int&gt;(FPClass::fp, number);
              cout &lt;&lt;  FPClass::fp(25, 45);
          }
  };
  
  
  void main()
  {
      FPClass::apply_function();
  }
  </code></pre>
  
  <p>What I want to achieve is, to assign the function pointer (<code>FPClass::fp</code>) by the template method (<code>Utility:get_function</code>).</p>
  
  <p>But the function pointer parameter is not modified (always null) by the called function (<code>Utility:get_function</code>).
  why is that?</p>