#pragma once #include "Pointer.h" template class Node { public: Node(T data) : mData(data) {} void addChild(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}; Ptr mLeftChild; Ptr mRightChild; }; template using NodePtr = Ptr >; template class Tree { public: Tree() { } void addRootNode(NodePtr root) { mRootNode = std::move(root); } Node* getRootNode() const { return mRootNode.get(); } private: NodePtr mRootNode; };