/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// distance example #include <iostream> #include <iterator> #include <list> using namespace std; int main () { list<int> mylist; for (int i=0; i<10; i++) mylist.push_back (i*10); list<int>::iterator first = mylist.begin(); list<int>::iterator last = mylist.end(); cout << "The distance is: " << distance(first,last) << endl; return 0; }
URL: http://www.cplusplus.com/reference/std/iterator/distance/