c++ - Definition of private weak_ptr in template class -



first of all: new c++, don't judge me. :)
tried defining static weak_ptr in template class in order use on instances.
this 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 error:

.../my_template.hpp:7: undefined reference 'my_template<my_class2>::wp' 

can help? don't it.

just add in same header:

template<class t> std::weak_ptr<t> my_template<t>::wp; 

works me! :)


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -