void Cinema::movieRunningAt(Movie& m, std::list<int>& movieList)
{
map<const Movie*, std::list<int>>::iterator mov_it;
mov_it = movie_times.find(&m);
if (mov_it == movie_times.end())
{
cout << "No movie was found" << endl;
return;
}
cout << mov_it->second << endl;
}
second is a list, so how do I print the found element out?
cout << mov_it->second << endl;
?
mov_it->second is a list container print it element need again traverse
Examples are as follows
map<int, list<int>> mapContainer{ {1, {1,2,3}}, {2, {2, 3, 4}} };
map<int, list<int>>::iterator it = mapContainer.find(1);
if (it != mapContainer.end())
{
for (int element : it->second)
{
cout << element << endl;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.