c++ - Returning multiple arguments from an overloaded operator -
i may not doing correctly possible multiple return values overload? using overload compare between objects in binary search tree.
i have 5 of them, post 2 (they 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 have 3 functions compare objects of "extpersontype" in bst. tried saw examples no luck (the output spits out randomly , 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 1 return statement @ time (i.e commenting out others). works isn't ideal.
any thoughts or things can try? alot in advance!
edit: posting further code.
i have function (or functions) matter in take string or int input. pass bst use search and/or print. value pass in this->getlastname() compares (either <, ==, etc) currentnodeinbinarytree.getlastname()
void dtbinarysearchtree<t>::search(node<t> *tree, t value) { if(tree){ search(tree->left, value); //recursive method locates matches, checks entire tree if( tree->value == value) cout << tree->value << endl; search(tree->right, value); }
i using above method @ people have same birthdays example (list people january birthdays).
again mentioned works, it's not method rather overload having trouble with. because have 2 other functions this... }
Comments
Post a Comment