mercredi 28 janvier 2015

Vector of unique_ptr member

I have the following:



typedef std::vector<std::unique_ptr<Node>> NodeList;
class Node
{
public:
Node();
Node(NodeType _type);
virtual ~Node();

NodeType getNodeType() const;
Node const* getParentNode() const;
// I want a member function to allow acces to the
// childNodes vector
bool hasChildNodes() const;

void setParent(Node* node);
void appendChild(std::unique_ptr<Node> node);
protected:
NodeType _nodeType;
Node* parentNode;
NodeList childNodes;
};


I want the user of the class to have access to the childNodes (read or read and write). How can I achieve that?


Aucun commentaire:

Enregistrer un commentaire