previous
|
start
|
next
Using Vectors to Collect Data Items
You must specify which slot you want to use with the
[]
operator.
salaries[4] = 35000;
The number inside the brackets is called an
index
.
Because salaries is a vector of double values, a slot such as
salaries[4]
can be used just like any variable of type double.
cout << salaries[4] << "\n";
In C++, the slots of vectors are numbered
starting at 0
.
previous
|
start
|
next