1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
// list::back
#include <iostream>
#include <list>
int main ()
{
std::list<int> mylist;
mylist.push_back(10);
while (mylist.back() != 0)
{
mylist.push_back ( mylist.back() -1 );
}
std::cout << "mylist contains:";
for (std::list<int>::iterator it=mylist.begin(); it!=mylist.end() ; ++it)
std::cout << ' ' << *it;
std::cout << '\n';
return 0;
}
| |