#include #include using namespace std; #include "vec.h" int main() { // --------------------------------------------------- // initialize v1 with 10 values... the multiples of 5 Vec v1( 10, 0 ); Vec::iterator p; Vec::size_type i; for ( p = v1.begin(); p != v1.end(); ++p ) *p = 5 * ( p - v1.begin() ); cout << "v1.size() = " << v1.size() << ". Should be 10.\n"; cout << "Contents of v1 (multiples of 5):"; for ( i = 0; i v2( v1 ); v2[ 9 ] = v2[ 0 ]; v2[ 8 ] = v2[ 1 ]; v2[ 7 ] = v2[ 2 ]; v2[ 6 ] = v2[ 4 ]; cout << "Contents of v1 (still multiples of 5):"; for ( i = 0; i v3; v3 = v2; v3.clear(); cout << "\nAfter copying v2 to v3 and clearing v3, v2.size() = " << v2.size() << " and v3.size() = " << v3.size() << endl; cout << "Contents of v2 (should be unchanged):"; for ( i = 0; i z; for ( i = 0; i<5; ++i ) z.push_back( sqrt( double(10*(i+1)) )); cout << "Contents of vector z: "; for ( Vec::const_iterator q = z.begin(); q != z.end(); ++q ) cout << " " << *q; cout << endl; return 0; }