create reference to template virtual class c++ -


i have such class

template<typename t>     class connectionstatus:     {     public:          virtual void setstatus(const t& status) = 0;         virtual t getstatus() = 0;     }; 

and want have reference class in class, this: connectionstatus<typename t>& status; compiler said error: template argument 1 invalid. how can make refernce template virtual class? thank help.

there 2 main possibilities: when know template argument should class , when don't.

for former, it's simple case of providing (say it's int in case):

struct myclass {     connectionstatus<int> &m_connection_status; }; 

if don't know argument, make class template class:

template <typename connectionstatustype> struct myclass {     connectionstatus<connectionstatustype> &m_connection_status; }; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -