#include #include #include #include #include "date.h" using namespace std; //Print the elements of CONTAINER c. //CONTAINER must have the members const_iterator, begin, and end. //The elements must be puttable. template void print(const CONTAINER& c) { for (typename CONTAINER::const_iterator it = c.begin(); it != c.end(); ++it) { const typename CONTAINER::value_type x = *it; cout << x << "\n"; } typename CONTAINER::size_type (CONTAINER::*p)() const = &CONTAINER::size; typename CONTAINER::size_type s = (c.*p)(); cout << "The container has " << s << " elements.\n\n"; } int main() { const int a[] = {10, 20, 30}; const size_t n = sizeof a / sizeof a[0]; list li(a, a + n); print(li); const date d[] = { 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 d / sizeof d[0]; vector v(d, d + dn); print(v); return EXIT_SUCCESS; }