C++ Iterator Library distance

C++ Iterator Library distance
返回C++,Iterator,Library,distance常用代码示例代码片段
#include <iostream>     
#include <iterator>     
#include <list>         

int main () {
   std::list<int> mylist;
   for (int i = 0; i < 5; i++) mylist.push_back (i*1);

   std::list<int>::iterator first = mylist.begin();
   std::list<int>::iterator last = mylist.end();

   std::cout << "The distance between first and last is: " << std::distance(first,last) << '\n';

   return 0;
}
原文链接:https://rumenz.com/examples/Cpp11/cplusplus-iterator-library-distance.html

【Linux常用命令速查手册】关注【入门小站】,后台回复 「1001」 自取。

点击下面标题即可获取对应PDF资料
↑回到顶部↑
入门小站 @2018