#pragma once #include template class Node { public: Node(T data) : mData(data) {} void addChild(std::unique_ptr child) { if(!mLeftChild) { mLeftChild = std::move(child); } else { mRightChild = std::move(child); } } bool isLeaf() const { return !mLeftChild && !mRightChild; } T getData() const { return mData; } Node* getLeftChild() const { return mLeftChild.get(); } Node* getRightChild() const { return mRightChild.get(); } private: T mData; unsigned char mTag{0}; std::unique_ptr mLeftChild; std::unique_ptr mRightChild; }; template using NodePtr = std::unique_ptr >; template class Tree { public: Tree() { } void addRootNode(NodePtr root) { mRootNode = std::move(root); } Node* getRootNode() const { return mRootNode.get(); } private: NodePtr mRootNode; };