// LevelOrder and the private recursive PreOrder,
// InOrder, and PostOrder mthods have been changed
// from template functions to integer functions because
// Visual C++ is unable to reslove overloaded functions
// when these were template functions
template<class T>
bool BinaryTree<T>::Root(T& x) const
{// Return root data in x.
// Return false if no root.
if (root) {x = root->data;
return true;}
else return false; // no root
}
template<class T>
void BinaryTree<T>::MakeTree(const T& element,
BinaryTree<T>& left, BinaryTree<T>& right)
{// Combine left, right, and element to make new tree.
// left, right, and this must be different trees.
// create combined tree
root = new BinaryTreeNode<T>
(element, left.root, right.root);
// deny access from trees left and right
left.root = right.root = 0;
}
template<class T>
void BinaryTree<T>::BreakTree(T& element,
BinaryTree<T>& left, BinaryTree<T>& right)
{// left, right, and this must be different trees.
// check if empty
if (!root) throw BadInput(); // tree empty
// break the tree
element = root->data;
left.root = root->LeftChild;
right.root = root->RightChild;
template <class T>
int BinaryTree<T>::Height(BinaryTreeNode<T> *t) const
{// Return height of tree *t.
if (!t) return 0; // empty tree
int hl = Height(t->LeftChild); // height of left
int hr = Height(t->RightChild); // height of right
if (hl > hr) return ++hl;
else return ++hr;
}