How to use extern keyword?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/1410563/what-is-the-difference-between-a-definition-and-a-declaration">What is the difference between a definition and a declaration?</a>  </p>
</blockquote>



<p>In my A.h file:</p>

<pre><code>extern int a,b;
private: int x,y;
public: A():x(1),y(2){}
void total();
</code></pre>

<p>In my B.h file:</p>

<pre><code>private: int a,b;
public: A():a(1),b(2){}
</code></pre>

<p>In my C.cpp file:</p>

<pre><code>#include "A.h"
void total(){
int total = a + b + x + y;}
</code></pre>

<p>When I build the program, It said that :<br/></p>

<pre><code>undefined reference to `a';
undefined reference to `b';
</code></pre>

<p>Can anybody tell me why ? Thank you.</p>
