Why can't we access global non-static variable from within a class?
<p>I defined the following structure to be used across the application by several classes.</p>

<p><em>ZHTypes.h</em></p>

<pre><code>#ifndef ZHTypes_h
#define ZHTypes_h

struct BeingHitParams
{
    bool isApplyKnockBack=true;
};
BeingHitParams *default_BeingHitParams_ptr = new BeingHitParams();

#endif
</code></pre>

<p>I defined a following variable </p>

<pre><code>default_BeingHitParams_ptr
</code></pre>

<p>for the case the I will use it in several places for default parameters of function as I don't need to create a new structure all the time.</p>

<p>Anyway, the above defined variable produces linking error whenever I refer to it in the code inside a class. But if I add <strong>static</strong> in front then it works fine.</p>

<pre><code>static BeingHitParams *default_BeingHitParams_ptr = new BeingHitParams();
</code></pre>

<p>So my question is why can't we access global but non-static variable from within a class?
I also want to know additional explanation of why C++ is restricted in accessing variable like in the situation above.</p>
