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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started