c++ private member declared in header vs static variable declared in cpp file
<p>i have a variable that i prefer to declare in a cpp file instead of the header file.  It should be accessible to objects of that class only.  This variable should have a separate copy for every object of that class.  Inheritance is not necessary.  </p>

<p>Normally, I'd just declare it in the class definition.</p>

<p>A.h:</p>

<pre><code>class A {
    private:
        int number;
}
</code></pre>

<p>But, can I do this instead?</p>

<p>B.h:</p>

<pre><code>class B {
    private:
        // nothing
}
</code></pre>

<p>B.cpp:</p>

<pre><code>static int number;
</code></pre>
