Answers for "how to loop through set members in cpp"

C++
0

loop through set c++

// set::begin/end
#include <iostream>
#include <set>

int main ()
{
  int myints[] = {75,23,65,42,13};
  std::set<int> myset (myints,myints+5);

  std::cout << "myset contains:";
  for (std::set<int>::iterator it=myset.begin(); it!=myset.end(); ++it)
    std::cout << ' ' << *it;

  std::cout << 'n';

  return 0;
}
Posted by: Guest on March-11-2021
0

cpp loop through object

std::list<Student>::iterator it;
for (it = data.begin(); it != data.end(); ++it){
    std::cout << it->name;
}
Posted by: Guest on April-29-2020

Browse Popular Code Answers by Language