Inheritance and static variables
<p>Here is my code - </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;conio.h&gt;

using namespace std;

class Base
{
public:
int a;

};

//int Base::a = 5;

class Derived : public Base
{

public:
int static a;
};

int main()
{
   Derived d;
   cout&lt;&lt;d.a;
   getch();
   return 0;
}
</code></pre>

<p>I get a linker error here. But when I do it the other way round - </p>

<pre><code>class Base
{
public:
int static a;

};

int Base::a = 5;

class Derived : public Base
{

public:
int a;
};
</code></pre>

<p>I get no error. Can someone please explain what is happening here.</p>
