#include#include int main() { std::list
myList = {1, 2, 3, 4, 5}; for (std::list ::iterator it = myList.begin(); it != myList.end(); ++it) { std::cout << *it << " "; } // Output: 1 2 3 4 5 return 0; }
#includeThese examples use the std namespace, which is part of the C++ Standard Library. The list class and its functions are part of the STL (Standard Template Library), which is also included in the C++ Standard Library.#include int main() { std::list
myList = {1, 2, 3, 4, 5}; myList.erase(myList.begin(), myList.end()); for (std::list ::iterator it = myList.begin(); it != myList.end(); ++it) { std::cout << *it << " "; } // Output: (nothing) return 0; }