Thank you for your reply.
I found the vector.clear line after I posted - a mistaken leftover from a prior debug. I apologize. Please disregard this line.
Line 15 is a typedef for the vector (and vector of vectors which is declared on line 55).
The for loop on lines 68-74 is what I am interested in and more specifically, how to de-reference it effectively.
While researching this on the web, I found two methods to execute this for loop to reach the members of vectors in nested for loops.
The first is the one I listed. The example of this method I found was for a single vector - not a vector of vectors. I took the liberty of trying to expand it. I think this is using pointers (the iterator) to the actual elements of the vector. The pointer is indexed from a start (p=v.begin(); ) to the last element (p=v.end(); ) and the elements are accessed with the syntax ((*p).strA if it were a single vector for loop.)
This is effective for a single vector, but I am unsure how to implement it with a vector of vectors and reference the appropriate start, end, and each element.
A second method of doing this I found used an ordinary int as indexes in the for loop as follows:
- for (int a=0; a<vx.size(); a++) {
-
cout << "a = " << a << endl;
-
for (int b=0; b<vx.at(a).size(); b++) {
-
cout << "b = " << b << endl;
-
cout << vx[a][b].strA << endl;
-
cout << vx[a][b].strB << endl;
-
cout << vx[a][b].strC << endl << endl;
-
}
-
cout << endl;
-
}
This works, but I still wonder how to get the original single for loop to work correctly as a nested for loop for a vector of vectors.