#include #include #include #include #include "date.h" using namespace std; //Print all the elements in the range [first, last). //ITERATOR must be an input iterator; its * must yield a puttable value. template void print(ITERATOR first, ITERATOR last) { for (; first != last; ++first) { cout << *first << "\n"; } } int main() { const int a[] = {10, 20, 30}; const size_t n = sizeof a / sizeof a[0]; print(a, a); //Print no elements (an empty range). list li(a, a + n); print(li.begin(), li.end()); //Print all the elements. cout << "\n"; const date da[] = { date(date::july, 4, 1776), date(date::october, 29, 1929), date(date::december, 7, 1941), date(date::july, 20, 1969), date(date::september, 11, 2001) }; const size_t dn = sizeof da / sizeof da[0]; vector v(da, da + dn); if (v.size() > 2) { print(v.begin() + 1, v.end() - 1); //Print all but 1st and last. } return EXIT_SUCCESS; }