Design an iterator to flatten a 2D vector. It should support the next and hasNext operations.
Implement the Vector2D class:
- Vector2D(int[][] vec) initializes the object with the 2D vector vec.
- next() returns the next element from the 2D vector and moves the pointer one step forward. You may assume that all the calls to next are valid.
- hasNext() returns true if there are still some elements in the vector, and false otherwise.
c++
1 | class Vector2D { |