Access on a std::vector<int,std::allocator<int>> (get the value the iterator is pointing at)

  2d, c++, iterator

I am trying to get exakt value my iterator is pointing at out of 2d array.
I have a 2d array and with max_element I got the maximum out of the values in the array.

With a "1d" iterator you can dereference the iterator and get the value (*iteratorOneD). But how can I do something like this with an 2d iterator like here:

vector<vector <int>>::iterator position;
position = std::max_element(Data.begin(), Data.end());

int max = *position[0];

cout<< *position << endl;

I tried a few things like this. But nothing worked yet. I receive this error.
C2440 "Initialisierung": "std::vector<int,std::allocator>" cant be converted to an int

The output of cout << *position << endl; is std::vector(1062256, 1027080).
I would like to be able to assign one of these values to int max.

Thanks in advance.

Source: Windows Questions C++

LEAVE A COMMENT