Is there a find()
function for list as there was in vector?
Is there a way to do that in list?
No, find() method is not a member of std::list
.
Instead, use std::find
from
std :: list < int > l;
std :: list < int > :: iterator pos;
l.push_back(1);
l.push_back(2);
l.push_back(3);
l.push_back(4);
l.push_back(5);
l.push_back(6);
int elem = 3;
pos = find(l.begin() , l.end() , elem);
if(pos != l.end() )
std :: cout << "Element is present. "<