First of all: I am new to C++, so don't judge me. :)
I tried defining a static weak_ptr in a template class in order to use it over all instances.
This is my code:
template <class T> class my_template : public my_class {
protected:
std::shared_ptr<T> sp;
virtual bool init_impl() {
sp = wp.lock();
...
return true;
}
private:
static std::weak_ptr<T> wp;
};
But compiling gives me the error:
.../my_template.hpp:7: undefined reference to 'my_template<my_class2>::wp'
Can anyone help? I just don't get it.