I may not be doing this correctly but is it possible to get multiple return values from an overload? I am using an overload to compare between objects in a Binary Search Tree.
I have about 5 of them, but I will post two (they are all similar anyways).
bool ExtPersonType::operator > (ExtPersonType bob){
return (this->getLastName() > bob.getLastName());
//return (getDate().getMonth() > bob.getDate().getMonth());
//return (this->getStatus() > bob.getStatus());
}
bool ExtPersonType::operator==(ExtPersonType bob){
return (this->getLastName() == bob.getLastName());
//return (getDate().getMonth() == bob.getDate().getMonth());
//return (this->getStatus() == bob.getStatus());
}
So I have three functions that compare objects of "ExtPersonType" in the BST. I tried this as I saw some examples but no luck (the output spits out randomly and data doesn't make sense).
bool ExtPersonType::operator > (ExtPersonType bob){
return (this->getLastName() > bob.getLastName() &&
getDate().getMonth() > bob.getDate().getMonth() &&
this->getStatus() > bob.getStatus());
}
If I do one return statement at a time (i.e commenting out the others). It works perfectly but obviously isn't ideal.
Any thoughts or things I can try? Thanks alot in advance!
Edit: Posting further code.
I have a function (or functions) for that matter in which I take a string or int as input. I pass that to my BST where I use it to search and/or print. The value that I pass in is this->getLastName() which compares to (either <, ==, etc) currentNodeinBinaryTree.getLastName()
void DTBinarySearchTree<T>::search(Node<T> *tree, T value)
{
if(tree){
search(tree->left, value); //recursive method that locates matches, checks entire tree
if( tree->value == value)
cout << tree->value << endl;
search(tree->right, value);
}
I am using the above method to look at all the people that have the same birthdays for example (list all people with January birthdays).
Again as mentioned everything works, so it's not the method but rather the overload that I am having trouble with. Because I have two other functions like this... }