Answer the question
In order to leave comments, you need to log in
Why doesn't the program enter the loop?
When you enter the correct data, that is, such a name that is in the list, the program writes that the element was not found. When debugging, I realized that the program does not enter the loop. I suspect that there is a very stupid mistake somewhere. Hope for help. Code attached:
for (auto& it : menu)
{
if (it.getName() == name)
{
cout << it << endl;
return;
}
}
cout << "There are no dish with name \"" << name << "\". Try again!" << endl;
Answer the question
In order to leave comments, you need to log in
The definition of it.getName() and name is missing, but I already assume (although I can’t be 100% sure without the necessary pieces of code) the program almost certainly goes into a loop, bypasses the entire menu list, and each time on the condition it.getName () == name compares addresses (and they are probably different), although you probably need to compare the contents directly.
Try https://www.cplusplus.com/reference/string/string/...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question