i have a recursive search function that returns the index of my vector where the search key was found However sometimes my vector can have two different positions that have the same key but my function only returns the first one.
here is my function:
int IdeaBank::twoSearchAND(int first, int last, string word_1, string word_2)
{
if (last == first)
return -1;
if (newIdea[first].foundWordInBoth(word_1)
&& newIdea[first].foundWordInBoth(word_2))
return first;
else
return twoSearchAND(first+1,last,word_1,word_2);
}
and here is how i am using it in my main
int first = 0;
int last = ideaBank.newIdea.size();
int index_found;
index_found = ideaBank.twoSearchAND(first, last, search_word1, search_word2);
ideaBank.displayIdeaByID(index_found);
my idea was to loop through n amount of times were n is the number of index's it returns but i wasnt too sure how to achieve that is there a way for me to get all the returned values from my function?
Edit: this is for a school project and must use recursion