vector<string> NOTE_DURATION[5];
How do i access say the last element in the the 3rd vector. |
NOTE_DURATION is an array of five vectors.
NOTE_DURATION[0] is the first vector.
NOTE_DURATION[1] is the second vector.
NOTE_DURATION[2] is the third vector.
NOTE_DURATION[3] is the fourth vector.
NOTE_DURATION[4] is the fifth vector.
So to get the 3rd vector,
NOTE_DURATION[2]
To get the last element of a vector, use the vector class function
back
http://www.cplusplus.com/reference/vector/vector/back/
NOTE_DURATION[2].back()
will give you the final element in this vector. Because it happens to be a vector of
string
objects, the final element is a
string
.
As an aside, why an array of vectors? Why not a vector of vectors?
vector< vector<string>> NOTE_DURATION;