// 面试题37:序列化二叉树 // 题目:请实现两个函数,分别用来序列化和反序列化二叉树。 #include "BinaryTree.h" #include <iostream> #include <fstream> using namespace std; void Serialize(const BinaryTreeNode* pRoot, ostream& stream)//序列化二叉树,ostream写文件流 { 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)//istream读文件流 { if (stream.eof())//检测stream是否读到头了 return false; char buffer[32]; buffer[0] = '