Question: Why isn't this function working?? Please Help. If info[0] = 5 and the item in the parameter is 5, the function isn't recognizing the that

Why isn't this function working?? Please Help.

If info[0] = 5 and the item in the parameter is 5, the function isn't recognizing the that both variables are the same.

this is how info was set

info = new ItemType[Max_Items];

template < class ItemType > int UnsortedList < ItemType >::findIndex (ItemType item) const //Searches the list for item and returns itembs index if the item was found. { ItemType vari; int index = 0; for (int i = 0; i < Max_Items; i++) { vari = item; cout << "vari: " << vari << " item: "<< item << " "; if (vari == info[i]) { index = i; } else { index = -1; } } return index; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!