// This is a derived from the code of example 20.14 of Deitel & Deitel

#include <iostream>
#include <vector>
using std::cout;
using std::cin;
using std::endl;
using std::vector;

template <class T>
void printVectorA(const vector<T> &vec)
{
    typename vector<T>::const_iterator iter;
    
    for (iter = vec.begin(); iter != vec.end(); iter++)
    {
        cout << *iter << ' ';
    }
    cout << endl;
}

template <class T>
void printVectorB(const vector<T> &vec)
{
    int n = vec.size();
    for (int i = 0; i < n; i++)
    {
        cout << vec[i] << ' ';
    }
    cout << endl;
}

int main()
{
    vector<int> v1;

    cout << "The initial size of v1 is: " << v1.size()
         << "\nThe initial capacity of v1 is: " << v1.capacity();
    v1.push_back(43);   // method push_back() is in every sequence collection
    v1.push_back(-31);
    v1.push_back(7);
    cout << "\nThe size of v1 is: " << v1.size()
         << "\nThe capacity of v1 is: " << v1.capacity() << endl;

    cout << "Contents of vector v1 using iterator notation: ";
    printVectorA(v1);

    double data[] = {1.37, 7.45, -3.14, 1.1, 42.0, -36.2};
    int numData = sizeof(data) / sizeof(data[0]);
    vector<double> v2(data, data + numData);
    cout << "\nThe size of v2 is: " << v2.size()
        << "\nThe capacity of v2 is: " << v2.capacity() << endl;

    cout << "Contents of vector v2 using iterator notation: ";
    printVectorA(v2);
    v2.push_back(2.71828);
    v2.push_back(3.1415926);
    cout << "\nThe size of v2 is: " << v2.size()
        << "\nThe capacity of v2 is: " << v2.capacity() << endl;

    cout << "Contents of vector v2 using array notation: ";
    printVectorB(v2);

    return 0;
}


