template <class type>
class List{
public:
List<type>::List(){
_list = new type[10];
}
List<type>::~List(){
delete this->_list;
}
private:
type* _list;
};
in main:
int main(){
List<std::string> l = List<std::string>();
return 0;
}
It happens only if I put non primitive variable in <> and dont use new.
I can avoid this by doing it like this: List<string> *l = new List<string>();
What I'am missing? In my mind it should perfectly fine.
Aucun commentaire:
Enregistrer un commentaire