我一直收到分段错误11,我不确定如何解决它。
void printLevelOrderHelper(Node<T> *root)
{
cout<<endl;
cout<<"Print Level Order Function"<<endl;
if(!root) return;
queue <Node<T>*> queue1;
Node<T> *temp = root;
while(temp!=nullptr)
{
cout<<temp->value<<" ";
if(temp->left)
queue1.push(temp->left);
if(temp->right)
queue1.push(temp->right);
temp = queue1.front();
queue1.pop();
}
}
我还包括了我的副本分配操作员,希望你们能告诉我什么是错的。
BST& operator=(BST & other)
{
cout << " [d] Copy assignment operator called. " << endl;
cout << " TODO: Implement copy assignment operator. " << endl;
if(root != other.root){
root = cloneTree(other.root);
}
return *this;
}