I am trying to search an array of object, for example lastName, a private variable of the object, however, the array might have more than one same last name from different objects.. i need to output all the same last name onto the screen, how should i do that?
code below will return index of the first target found.... how do i finish searching the whole array and display them? thank you
int searchLN(Name *inName[], string targetLastName, int j)
{
int index=0;
bool found = false;
while( (!found)&& (index<j) )
{
if((*inName[index]).getLastName()== targetID)
{
found= true;
}
else
{
index++;
}
}
if(found)
return index;
else
return -1;
}