#include using namespace std; template void print(vector &v) { typename vector::iterator it = v.begin(); while (it != v.end()) { cout << *it << " "; it++; } cout << endl; } int main() { int arr1[5] = {1, 2, 3, 4, 5}; vector v1(arr1, arr1 + 5); print(v1); cout << "first element is: " << v1.front() << endl; cout << "first element addr is: " << &v1.front() << endl; // 与 day9/d7.cpp 中的 first addr 不同 cout << "last element is: " << v1.back() << endl; cout << "last element addr is: " << &v1.back() << endl; // 与 day9/d7.cpp 中的 first addr 不同 return 0; }