template <typename T> void NonPostRecursiveTraverse(CTreeNode<T>* pTreeNode) { printf(" "); if (!pTreeNode) { return; } g_stack.Push(pTreeNode); g_stack.Push(pTreeNode->pRChild); pTreeNode = pTreeNode->pLChild; while (true) { while (pTreeNode) { if (pTreeNode->nData == 1)//last node { printf("PostNode:%d ", pTreeNode->nData);//visit return; } g_stack.Push(pTreeNode); g_stack.Push(pTreeNode->pRChild); pTreeNode = pTreeNode->pLChild; } pTreeNode = g_stack.Pop(); printf("PostNode:%d ", pTreeNode->nData);//visit if (g_stack.IsEmpty()) { break; } if (pTreeNode->pRChild) { pTreeNode = g_stack.Pop(); } else { pTreeNode = pTreeNode->pRChild; } } }