mardi 31 mars 2015

How to define a template class for a linked list node with pointer as template type

How to define a node template for a linked list? I also want to keep the pointer type as template parameter so that I can change it to unique_ptr or shared_ptr depends on what available.



template<typename T, typename NodePtr>
struct node{
T data;
NodePtr parent = nullptr;
};


The question is that how to initiate this class so that Nodeptr will be shared_ptr < Node <T ,what?> > type?


Aucun commentaire:

Enregistrer un commentaire