// 面试题37:序列化二叉树 // 题目:请实现两个函数,分别用来序列化和反序列化二叉树。 #include <cstdio> #include "BinaryTree.h" #include <iostream> #include <fstream> using namespace std; void Serialize(const BinaryTreeNode* pRoot, ostream& stream) { if (pRoot == nullptr) { stream << "$,"; //这地方是双引号 return; } stream << pRoot->m_nValue << ','; //当前节点值 Serialize(pRoot->m_pLeft, stream); Serialize(pRoot->m_pRight, stream); } bool ReadStream(istream& stream, int* number) { if (stream.eof()) //序列到尾部 return false; char buffer[32]; //缓存器, 存放一个节点的值 buffer[0] = '