title: Static variable in a Header File
body: <p>Static variable has file scope. Say I have two following files:<br> </p>
  
  <ul>
  <li>file1.h </li>
  <li>file1.cpp </li>
  <li>file2.h </li>
  <li>file2.cpp</li>
  </ul>
  
  <p>I have declared static variable say <code>static int Var1</code> in both the header files. Both <code>file1.h</code> and <code>file2.h</code> are included in <code>main.cpp</code> file.</p>
  
  <p>I did this since the static variable will have file scope so it won't conflict each other.
  But after compilation I found it is showing conflict.</p>
  
  <p>Now static variable is behaving like a <code>extern</code> variable. On the other hand if I declare the static variable in both .cpp files, it compiles well.</p>
  
  <p>I am unable to understand this behavior.</p>
  
  <p>Can any body explain how scope and linkage are working in this scenario.</p>