#include <list>
#include <string>
#include <iostream>
using namespace std;
int main()
{
list<int> list1;
size_t n = 10;
double val = 3.14;
list<double> list2(n, val);
list<double> list3(list2);
cout << "Size of list1 " << list1.size() << endl;
cout << "Size of list2 " << list2.size() << endl;
cout << "Size of list3 " << list3.size() << endl;
// populate a new list with the elements of list2
list<double> list4;
list<double>::const_iterator i;
for (i = list2.begin(); i != list2.end(); ++i)
{
list4.push_back(*i);
}
// Print every character in the list
for (i = list4.begin(); i != list4.end(); ++i)
{
cout << *i << ",";
}
cout << endl;
return 0;
}
|