// vectors.cxx // This short program introduces the vector class. #include // Provides size_t and EXIT_SUCCESS #include // Provides setw #include // Provides cout #include // Provides assert() #include // Provides the vector class! using namespace std; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ int main( ) { // Make a vector: vector test_vec; size_t i; // For an index // Print how big the vector is: cout << "test_vec has " << test_vec.size() << " elements." << endl; // Add things to a vector: test_vec.push_back(-10); test_vec.push_back(-20); test_vec.push_back(-30); // Print how big the vector is: cout << "test_vec has " << test_vec.size() << " elements." << endl; // Print the vector's elements: for (i = 0; i < test_vec.size(); i++) { cout << test_vec[i] << endl; } return EXIT_SUCCESS; } //------------------------------------------------------------------------------