// MT4Q2c.cpp - Array with iterator from std::vector #include #include // Question MT4Q2 asks for an array class, not an // STL container wrapper, but I'll give partial credit // for a solution that behaves like an array, e.g., // like the following: template class Array { public: typename typedef std::vector::iterator iterator; // This Array doesn't need copy, assign, or destructor // since its vec member has correct operations, so // compiler will generate correct operations. Array() { for(size_t i=0; i vec; }; template void display(Array& arr) { std::cout << "\n "; Array::iterator iter, last; last = --(arr.end()); for(iter=arr.begin(); iter!=last; ++iter) std::cout << *iter << ", "; std::cout << *last << "\n"; } int main() { double dtemp[] = { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5 }; Array arr(dtemp); display(arr); }