/* This program shows another way of using dynamic arrays in C++ */ #include // for cout, cin, etc #include // include the STL vector "container" type #include #include using namespace std; int main() { vector a(10); // vector of 10 integers vector c(10,15); // vector of 10 integers set to value "15" a = c; // a become a copy of c vector b(100); // vector of 100 doubles cout << "The size of vector b is: " << b.size() << endl; double val; // input value cout << "Type a number: "; cin >> val; b.push_back(val); cout << "Now b has the size: " << b.size() << endl; cout << endl << "Here are the values in the vector a:" << endl; typedef vector::iterator Iter; for (Iter i = a.begin(); i != a.end(); ++i) { cout << *i << endl; } ostream_iterator out(cout, " "); copy(a.begin(), a.end(), out); cout << endl; }