title: include guards not working
body: <p>I've defined a util.h file with functions that i want to use throughout several different other files.  This header has an include guard, however when i use it in two different files, I get a <code>multiple definition of...</code> error.  What am i doing wrong?</p>
  
  <p>I've read <a href="https://stackoverflow.com/questions/8108072/c-include-guards-do-not-seem-to-be-working#answer-8108125">this</a> but this pertains to variable declaration/definition.  <a href="https://stackoverflow.com/questions/1787822/why-arent-include-guards-or-pragma-once-working#answer-1787830">This</a> answer seems more relevant but it's not clear to me how i can fix this.</p>
  
  <pre><code>// util.h
  // include lots of standard headers
  #include ...
  
  #ifndef UTIL_H
  #define UTIL_H
  
  using namespace std;
  // multiple definition of `randarr(int, int, int)`
  int* randarr(int size, int min, int max) {
      int *ret = new int[size];
      for (int i=0; i&lt;size; i++)
              ret[i] = (int) (((double) rand() / RAND_MAX) * max) + min;
      return ret;
  }
  // no error
  template&lt;typename T&gt; void printarr(T* v, int begin, int end) {
      for (int i=begin; i&lt;end; i++)
      cout &lt;&lt; v[i] &lt;&lt; " ";
      cout &lt;&lt; endl;
  }
  // multiple definition of `is_prime(int)`
  bool is_prime(int n) {
      if (n == 2 || n == 3 || n == 5) return true;
      if (n &lt;= 1 || (n&amp;1) == 0) return false;
  
      for (int i = 3; i*i &lt;= n; i += 2)
              if (n % i == 0) return false;
  
      return true;
  }
  #endif
  </code></pre>
  
  <hr>
  
  <pre><code>// example.cpp
  #include ...// lots of standard includes
  #include "util.h"
  void f() {
      randarr(...);
      printarr(...);
      is_prime(...);
      ...
  }
  </code></pre>
  
  <hr>
  
  <pre><code>// Main.cpp
  #include "util.h"
  int main() {
  
  }
  </code></pre>