#include <list>
#include <vector>
#include <iostream>
using namespace std;
template <class T>
void print(T& c){
for( typename T::iterator i = c.begin(); i != c.end(); i++ ){
std::cout << *i << endl;
}
}
int main( )
{
const double data[] = { 3.14, 2.78, 1.51, 7.66, 9.65 };
list<double> original( data, data + sizeof( data ) / sizeof( data[0] ) );
vector<double> vector_data( 3, 3.33 );
list<double> list_data( 4, 4.44 );
// show results
print( original );
print( vector_data );
print( list_data );
// assign a list to a list
list_data = original;
// create an empty vector of int's and assign a list of doubles to it
vector<int> v;
v.assign( original.begin(), original.end() );
// show results
print( list_data );
print( v );
}
|