I am trying to get maximum value my iterator is pointing at out of 2d array.
Example
Input
Data = {{}, {3,11,4}, {1,2}, {5,6}};
Output
max = 11
I have a 2d array and with max_element I tried to get the maximum out of the values in the array.
With a 1d iterator you can dereference the iterator and get the value i.e. *iteratorOneD. But how can I do something like this with a 2d iterator?
I tried a few things like this.
vector<vector <int>>::iterator position;
position = std::max_element(Data.begin(), Data.end());
int max = *position[0];
cout<< *position << endl;
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.