I saw an interview question, which was asked to use "iterator" to read vector<vector<int>>
. We have to design the necessary interface?
Quite confusing about does this question want to ask? Or how to answer this kind of question.
I can imagine that it intends to test C++ STL implementation and objected-oriented design.
Matrix
is in 3*4 dimension. If needed to access only through iterators, this should give you an idea -Just for fun, here is what my answer would have been to "Please use an iterator to print the values of a
vector<vector<int> >
." :You may find this website to be useful: http://en.wikipedia.org/wiki/Iterator#C.2B.2B