referencing element in vector of vectors

If I have a vector of vectors defined:

static vector< vector<int32_t> > coeffTable;

Is this not the correct way to reference an element?

1
2
	vector<int32_t>::iterator iter;
	iter = coeffTable.at(i).at(0);


The compiler's giving me a rather cryptic error.
1
2
3
vector< vector<int32_t> > coeffTable;

vector<int32_t>::iterator iter = coeffTable[i].begin();
int32_t value = coeffTable[i][0]; (or coeffTable.at(i).at(0) if you don't know what i is and whether inner vector is empty).

Accessors such as operator[] and at() return values/references, not iterators.
Thanks for the replies, guys.

The vector needs to be static. Am I to understand that I should be using brackets instead of the at() function? I thought that wasn't recommended.
Your problem is that you're setting the iterator to a reference to a variable rather than an iterator.

at() and [] return references to individual values in your vector.

begin(), end(), rbegin(), and rend() return iterators that you can adjust if you need to with the +, -, +=, -=, ++, and -- operators. You probably want begin().

-Albatross
Ahhh, OK. I got it now. So, my iterator assignment is now:

iter = coeffTable.at(i).begin();

and all seems to be working fine.

Thanks to all for the assistance.
Topic archived. No new replies allowed.