title: header file include-loop and multiple definition
body: <p>I have a <code>util.h</code> containing a function which will be used in <code>a.h</code> and 'b.h', and further more, <code>a.h</code> and <code>b.h</code> will include each other in order to access some classes defined in each other.</p>
  
  <pre><code>//util.h
  
  #ifndef _UTIL_H_
  #define _UTIL_H_
  
  #include &lt;iostream&gt;
  
  void foo()
  {
      std::cout &lt;&lt; "foo\n";
  }
  
  #endif
  
  //a.h, it has a a.cpp
  #ifndef _A_H_
  #define _A_H_
  
  #include "util.h"
  #include "b.h"
  
  //some classes' definition
  
  #endif
  
  //b.h, it has a b.cpp
  #ifndef _B_H_
  #define _B_H_
  
  #include "util.h"
  #include "a.h"
  
  //some classes' definition
  
  #endif
  </code></pre>
  
  <p>My problem is that, I got <code>multiple definition</code> error for <code>foo</code>. How?</p>
  
  <p>I thought the problem might be that, <code>a.h</code> includes <code>util.h</code> and <code>b.h</code>, and <code>b.h</code> includes <code>util.h</code> once again, so I got multiple def error. But it can't seem to make sense, because in <code>util.h</code> I wrote <code>#ifndef/#define</code> guards.</p>
  
  <p>Anyone can give me a help, thanks.</p>