how to list in c++ code example
Example 1: how to make a list in c++
#include <list>
std::list<int> ints;
Example 2: how to write C++ list
#include <iostream>
#include <list>
int main ()
{
std::list<int> first;
std::list<int> second (4,100);
std::list<int> third (second.begin(),second.end());
std::list<int> fourth (third);
int myints[] = {16,2,77,29};
std::list<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
std::cout << "The contents of fifth are: ";
for (std::list<int>::iterator it = fifth.begin(); it != fifth.end(); it++)
std::cout << *it << ' ';
std::cout << '\n';
return 0;
}