我正在使用二叉查找樹。在這裏我正在寫一個函數來從樹中刪除一個項目。在下面的代碼:複製構造函數
if(root = NULL)//if there is nothing in the tree
{
cout<<"the Tree is empty"<<endl;//ouput to the screen
return;//exit the function
}
bool isFound = false;//tells us if the item is found
Node* tmp = new Node();//declare a temp pointer
Node* tmp2 = new Node();;//declare a temp pointer
tmp* = *root;//assign the pointer to something
它調用拷貝構造函數,但我有它,現在我只是在複製這樣的價值觀:
Node& Node::operator= (const Node& node)
{
data = node.data;
left = node.left;
right = node.right;
return *this;
}
有什麼實際問題? – Michael 2013-03-13 11:58:55