Is the following code is correct if I have it in a header file?
template <T> Stopwatch *Stopwatch::m_instance = nullptr;
class Stopwatch
{
std::clock_t m_lastStep;
std::clock_t m_start;
static Stopwatch *m_instance;
};
ok With the help of everybody, I could manage to compile it as follow:
The idea is to have the class definition and static member initialization on the one header file. Please note that I use template but never used its type.
I remove other part of code for simplicity.
template <typename T>
class Stopwatch
{
std::clock_t m_lastStep;
std::clock_t m_start;
static Stopwatch *m_instance;
};
template <typename T>
Stopwatch<T> *Stopwatch<T>::m_instance = nullptr;
Now I need to see if it really works!