0001 template <typename T> BNP<T> clone(BNP<T> p, BNP<T> t) { //深复制 0002 if (!t) return nullptr; 0003 BNP<T> x = new BinNode<T>(t->data, p, nullptr, nullptr, t->height, t->color); //先序 0004 x->lc = clone(x, t->lc); x->rc = clone(x, t->rc); 0005 return x; //由t复制出x 0006 } //clone: p ~ Parent; t ~ source Tree 0007 template <typename T> BinTree<T>& BinTree<T>::operator=(const BinTree<T>& t) { //赋值 0008 if (_root != t._root) 0009 { remove(_root); _root = clone<T>(nullptr, t._root); _size = t.size(); } 0010 return *this; 0011 } //operator=