title: pointers as template arguments in c++
body: <p>I get a link error of an unresolved external symbol "reducedFraction(uint64_t*,uint64_t*)" from the following code.</p>
  
  <p>in main.cpp I have:  </p>
  
  <pre><code>template &lt;typename T&gt;  T greatestCommonFactor(T a, T b) {
      //make b the smaller
      T t;//temp
      if (b &gt; a)
      {
          t = a;
          a = b;
          b = t;
      }
      //archimedes method
      while (b != 0)
      {
          t = b;
          b = a % b;
          a = t;
      }
      return a;
  }
  
  template &lt;typename T&gt;
  void reduceFraction(T *a, T *b) {
      T gcf = greatestCommonFactor(*a, *b);
      *a /= gcf;
      *b /= gcf;
  }
  
  int main() {
      uint64_t numerator;
      uint64_t denominator;
  
      numerator = 121;
      denominator = 55;
      cout &lt;&lt; numerator &lt;&lt; " " &lt;&lt; denominator &lt;&lt; endl;
  
      reduceFraction(&amp;numerator, &amp;denominator);
  
      cout &lt;&lt; numerator &lt;&lt; " " &lt;&lt; denominator &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The functions greatestCommonFactor and reduceFraction work fine when I have "uint64_t" as just non-template function instead of "T". It turns out when I change just reduceFraction to a non-template function the link error now is with greatestCommonFactor.</p>
  
  <p>Changing first line of reduceFraction to</p>
  
  <pre><code>auto gcf = greatestCommonFactor(*a, *b);
  </code></pre>
  
  <p>does not do the trick.</p>
  
  <p>What am I doing wrong? It should be obvious that I am trying to reduce a fraction.  When I write the code as a non-template function it works just fine.  Thanks in advance.</p>
  
  <pre><code>LNK2019 unresolved external symbol "void __cdecl reduceFraction(unsigned __int64 *,unsigned __int64 *)" (?reduceFraction@@YAXPA_K0@Z) referenced in function _main  visualStudioEuler   C:\Users\George\Documents\Visual Studio 2015\Projects\visualStudioEuler\visualStudioEuler\main.obj  1
  </code></pre>
  
  <p>A couple of side notes:
  I am using visual studio community on windows 10 with code that was "ported" from CodeLite, if that helps. I have had some trouble with "stdafx.h" and other header files because of it.</p>