how to iterate over a list in c++ code example
Example 1: traverse through list c++
for (auto it = mylist.begin(); it != mylist.end(); ++it)
cout << ' ' << *it;
Example 2: cpp loop through object
std::list<Student>::iterator it;
for (it = data.begin(); it != data.end(); ++it){
std::cout << it->name;
}
Example 3: c++ loop trhought object
for (auto const& i : data) {
std::cout << i.name;
}