// Prog: vector_test.cpp // tests your implementation of ifmp::vector #include // std::sort #include // std::cout #include "vector.cpp" // ifmp::vector class int main() { ifmp::vector a; // default constructor, start filling the vector: std::cout << a.size() << " " << a.capacity() << "\n"; a.push_back(4); std::cout << a.size() << " " << a.capacity() << "\n"; a.push_back(1); std::cout << a.size() << " " << a.capacity() << "\n"; a.push_back(3); std::sort(a.begin(), a.end()); // sort the vector a with std::sort for(int i=0; i<3; ++i) std::cout << a[i] << " "; std::cout << "\n"; ifmp::vector b (3,2); // construct and initialize for(int i=0; i<3; ++i) std::cout << b[i] << " "; std::cout << std::endl; b.push_back(0); a = b; // operator= std::cout << a.size() << " " << a.capacity() << "\n"; ifmp::vector c = a; // copy constructor std::cout << c.size() << " " << c.capacity() << "\n"; c.clear(); // the size is 0, capacity may be larger std::cout << c.size() << " " << c.capacity() << "\n"; c.push_back(1); c[0] = 3; // operator[] const ifmp::vector d = c; // d is a const vector std::cout << d[0] << std::endl; // here we need operator[] const return 0; }