This is a constructor for a binary tree that creates a copy of the tree given as argument....
Code:
Tree(const Tree<T>& aTree){
this->ghost = new Node<T>();
if(aTree.treeIsEmpty()){
this->root = this->ghost;
}else{
this->root = new Node<T>(aTree.getRoot()->key, 0, this->ghost, this->ghost);
this->treeCopyFill(aTree, aTree.getRoot(), this->root);
}
}
and its subroutine treeCopyFill...
Code:
void treeCopyFill(const Tree<T>& aTree, Node<T> * theOriginalFatherNode, Node<T> * theCopyFatherNode){
if(!aTree.isLeef(theOriginalFatherNode->left)){
theCopyFatherNode->left = new Node<T>(theOriginalFatherNode->left->key, theCopyFatherNode, this->ghost, this->ghost);
treeCopyFill(aTree, theOriginalFatherNode->left, theCopyFatherNode->left);
}
if(!aTree.isLeef(theOriginalFatherNode->right)){
theCopyFatherNode->right = new Node<T>(theOriginalFatherNode->right->key, theCopyFatherNode, this->ghost, this->ghost);
treeCopyFill(aTree, theOriginalFatherNode->right, theCopyFatherNode->right);
}
}
When I compile with GCC, I get the following error about 5 times....
passing const Tree<T> as 'this' argument of return_type Tree<T>::method [with T=int] discards qualifier
Can anyone explain what's happening and what can I do to solve the problem?