// 操作结果:层次遍历二叉树
template void BinaryTree::LevelOrder(void (*visit)(const ElemType &)) const {
// 队列 BinTreeNode *t = root;
LinkQueue<BinTreeNode *> q; // 从根结点开始进行层次遍历
if (t != NULL) q.InQueue(t);// 如果根非空,则入队
while (!q.Empty()) {// q非空,说明还有结点未访问
q.OutQueue(t);
(*visit)(t->data);
if (t->leftChild != NULL)// 左孩子非空 q.InQueue(t->leftChild); // 左孩子入队
if (t->rightChild != NULL)// 右孩子非空 q.InQueue(t->rightChild); // 右孩子入队
} }