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