#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 int num_elements = 4;
const double data[num_elements] = { 4.78, 6.97, 8.81, 9.02 };
list<double> l( data, data + num_elements );
const char* flavors[] = { "A", "B", "C" };
vector<string> v( flavors,
flavors + sizeof( flavors ) / sizeof( flavors[0] ) );
// display containers
print( l );
print( v );
}
|