dimanche 5 juin 2016

what's the difference between *iter.first and iter->first?

vector<int> a = { 1,2,3,4,5,6,7 };
pair<vector<int>, vector<int>::iterator> pair_of_itr;    //not working showing wrong directional error!
auto pair_of_itr = minmax_element(a.begin(), a.end());
cout << *pair_of_itr.first << " " << *pair_of_itr.second << endl;  // working with auto  but not with the PAIR of iterator.
//cout << pair_of_itr->first << " " << pair_of_itr->second << endl  // not working
return 0;

here i have explained via comments. plz do refer comments.

Aucun commentaire:

Enregistrer un commentaire