Why does negating a static member variable produce a linker error?
<p>Please consider the following mini example</p>

<pre><code>// CFoo.hpp
class CFoo{
private:
    static const double VPI = 0.5;    
public:
    double getVpi();
};

// CFoo.cpp
#include "CFoo.hpp"    
double CFoo::getVpi(){
    double x = -VPI;
    return x;
}

// main.cpp
#include "CFoo.hpp"    
int main(){
    CFoo aFoo();
    return 0;
}
</code></pre>

<p>Lining the program with gcc version 4.5.1 produces the error <code>CFoo.cpp: undefined reference to CFoo::VPI</code>. The error dose <strong>not</strong> occur if</p>

<ul>
<li>VPI is not negated</li>
<li>the negation is written as <code>double x = -1 * VPI;</code></li>
<li>Declaration and definition of class CFoo happen in the same file</li>
</ul>

<p>Do you know the reason for this error?</p>
