/* main.cc - a program to perform functions on vectors of integers. */ #include // includes the prototype for cout and << #include // includes the prototype for "abort" #include "vector.h" void PrintVector (Vector &v); // warns compiler of future definition main() { // create a vector object of size 8, all initialized to 0; Vector *v1 = new Vector (4,0); // fill in some values; (*v1)[0] = 4; (*v1)[1] = 8; (*v1)[2] = 3; (*v1)[3] = 7; cout << "Initial array: "; PrintVector(*v1); Vector *v2, *v3, *v4; // Testing basic constructors (tests for part 1) v2 = v1; cout << "v2 == v1 is " << (v2 == v1) << endl; cout << "*v2 == *v1 is " << (*v2 == *v1) << endl; v3 = new Vector(*v1); cout << "v3 == v1 is " << (v3 == v1) << endl; cout << "*v3 == *v1 is " << (*v3 == *v1) << endl; v4 = new Vector(); *v4 = *v1; cout << "v4 == v1 is " << (v4 == v1) << endl; cout << "*v4 == *v1 is " << (*v4 == *v1) << endl; // Put your part 2 solution here. // Tests for part 3 cout << "Testing part 3" << endl; cout << " *v1 = " << *v1; cout << " *v2 = " << *v2; cout << " *v3 = " << *v3; cout << " *v4 = " << *v4; // Clean up delete v1; delete v3; delete v4; } // Postcondition: prints vector v on the standard output steam. void PrintVector (Vector &v) { cout << "["; for (int i = 0; i < v.size()-1; i++) { cout << v[i] << ", "; } if (v.size()>0) { cout << v[v.size()-1] << "]" << endl; } else { cout << "]" << endl; } }