You know how you have a function prototype, and then a separate function body?
Like... consider the following program:
1 2 3 4 5 6
void SomeFunction();
int main()
{
SomeFunction();
}
That will compile OK, but because SomeFunction has no body, you'll get a linker error.
Static member vars are the same way. The declaration in the header is the "prototype", but you need to give them a "body", otherwise you get the linker error you're getting.
1 2 3 4 5
// in your header
class MyClass
{
staticint foo; // the "prototype"
};
1 2 3 4
// in your cpp file
#include "myclass.h"
int MyClass::foo; // the "body". Note: no static keyword here
// in your header
class MyClass
{
staticint foo; // the "prototype"
};
// or in your case...
class computeChiSquare: public chiSequare
{
static std::vector< resultBackup > testValuesCashe;
};
1 2 3 4 5 6 7 8 9
// in your cpp file
#include "myclass.h"
int MyClass::foo; // the "body". Note: no static keyword here
// or in your case...
std::vector< resultBackup > computeChiSquare::testValuesCashe;
The "prototype" (ie: staticint foo;) doesn't actually create the variable. It just tells the compiler that the variable exists somewhere. To use that variable, you need to instantiate it... or "give it a body". That is done by putting int MyClass::foo; in a cpp file.