I am programming a template matrix with multi-threading. I need my matrix to be able to work with this code line (which i cannot change, it's a demand from my program):
Matrix<Complex>::setParallel(false);
so for this parallel (which is a bool decides if to use multi-threading or not) must be static.
So at start i defined it like that:
template<class T>
class Matrix
{
private:
...
public:
static bool parallel;
...
};
but then i got this error:
... undefined reference to 'Matrix<int>::parallel'
after a quick search i got to this question in stack overflow: Undefined reference to a static member
so i go ahead and to what the answers said. so i changed my code to:
template<class T>
class Matrix
{
private:
...
public:
static bool Matrix::paraller;
...
};
and now i get this error:
extra qualification 'Matrix<T>::' on member 'paraller' [-fpermissive]
(note: i also tried static "bool Matrix::paraller;" instead, didn't help.
now i don't know how to get rid of the extra qualification error without getting back the undefined reference again.
if that matters, the whole code is in a file named: "Matrix.hpp", which i cannot change (another demand from my project).
what should i do?