#include #include #include #include "date.h" using namespace std; void print(const int *first, const int *last); void print(vector::const_iterator first, vector::const_iterator last); int main() { int a[] = {1776, 1929, 1941, 1969, 2001}; const size_t n = sizeof a / sizeof a[0]; print(a, a + n); //Print all the elements. cout << "\n"; if (n > 2) { print(a + 1, a + n - 1); //Print all but 1st and last. cout << "\n"; } 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.begin(), v.end()); //Print all the elements. cout << "\n"; if (v.size() > 2) { print(v.begin() + 1, v.end() - 1); //Print all but 1st and last. } return EXIT_SUCCESS; } void print(const int *first, const int *last) { for (; first != last; ++first) { cout << *first << "\n"; } } void print(vector::const_iterator first, vector::const_iterator last) { for (; first != last; ++first) { cout << *first << "\n"; } }