Vectors in C++ are a way of storing many things of the same type, similar to arrays, but that can be resized automatically, unlike regular C++ arrays. To use them you have to include the vector header file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <vector>
#include <iostream>
usingnamespace std; // put this or you have to declare vector, cout and endl in the std namespace.
int main(void)
{
vector<double> nums(10); // This creates a vector of 10 doubles.
// the indexes are 0 to 9.
nums[3] = 3.1415962;
nums[2] = 2.718281828459;
cout << nums[3] << endl;
return 0;
} // main