I have a static array inside a class template. The linker complains about a undefined symbol and even after applying the tips I saw on the web, I can't figure out what goes wrong.
Header
template<unsigned int N1, unsigned int N2>
class Foo
{
private:
static const int Size = N1 * N2;
public:
// stuff
private:
static float mArray[Size];
}
CPP
template <unsigned int N1, unsigned int N2>
float Foo<N1, N2>::mArray[size] = {0};
The linker complains about Foo<...>::mArray not being defined. I got it to compile (and link) when I move the definition to the header but I know that this is bad practice for statics. What is the best approach here?
Cheers