0
I created the "checkCase4" function in my Tree class and within it I make 2 class methods (rotate_left and rotate_right).
Function:
void checkCase4(Node *child, Node *grand) {
if (child == child->parent->right && child->parent == grand->left) {
rotate_left(grand, child->parent, child);
child = child->left;
}
else if (child == child->parent->left && child->parent == grand->right) {
rotate_right(grand, child->parent, child);
child = child->right;
}
checkCase5(child, child->parent->parent);
}
Method:
void Tree::rotate_right(Node *gr, Node *par, Node *ch){
...
}
And the following error returns to me:
rbt.cpp: In Function ːvoid checkCase4(Node*, Node*)':
rbt.cpp:32:44: error: ṃ rotate_left' was not declared in this Scope
rotate_left(grand, Child->Parent, Child);
rbt.cpp:36:45: error: ṃ rotate_right' was not declared in this Scope
rotate_right(grand, Child->Parent, Child);
If anyone can help me, I’d really appreciate it.
There is some problem that goes beyond what you posted, need to see the whole structure.
– Maniero
checkCase4
does not seem to be an instance method. So, if you want to ask the tree to rotate, you should pass the tree. Something like this:arvore.rotate_left
(if it has the object or reference) orarvore->rotate_left
(in case you have the pointer)– Jefferson Quesado