title: how does the inline function work in C++?
body: <p>now I have 2 c++ source files: test9.cpp test10.cpp, they both have a inline function with the same name.</p>
  
  <p>test9.cpp:</p>
  
  <pre><code>1 #include &lt;iostream&gt;
  2 using namespace std;
  3 void test();
  4 inline void f1()
  5 {
  6     cout &lt;&lt; "inline f1 in test9.cpp" &lt;&lt; endl;
  7 }   
  8 int main()
  9 {
  10     f1();
  11     test();
  12     return 0;
  13 } 
  </code></pre>
  
  <p>test10.cpp:</p>
  
  <pre><code>1 #include &lt;iostream&gt;
  2 using namespace std;
  3 inline void f1()
  4 {
  5     cout &lt;&lt; "inline f1 in test10.cpp" &lt;&lt; endl;
  6 }   
  7 void test()
  8 {
  9     f1();
  10 } 
  </code></pre>
  
  <p>now compile them with g++:   g++ test9.cpp test10.cpp    ./a.out   I get the following result:</p>
  
  <pre><code>inline f1 in test9.cpp
  inline f1 in test9.cpp
  </code></pre>
  
  <p>what's wrong? I thought it would be: "inline f1 in test9.cpp inline f1 in test10.cpp"
  who can tell me why? how does the g++ compiler treats the inline function?</p>