c++ - data member 'vec' cannot be a member template -


i have following 2 lines in header in order declare vector containing template:

template <class t>     std::vector <t> vec; 

however following error: data member 'vec' cannot member template did wrong? edit: don't know understood correctly, trying declare vector contains template, know can done 1 can have following:

template <class t> void funct(vector <t> v){   } 

this function takes vector of template it's parameter, wish same thing except declaring vector in header in order allow vector contain anything.

the template <> statement used when declaring function template or class template. example can use when declare (and define) class:

template <typename t> class templateclass {     /* definition */ }; 

or function:

template <typename t> void templatefunc(t value) {     /* definition */ } 

when creating instance of class, can't use template <> statement. instead specify template parameter this:

templateclass<int> tc; 

and when calling template function:

int = 1; templatefunc(i); // <-- automatic template deduction int. 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -