distance for vector : distance « STL Algorithms Helper « C++






distance for vector

 
 

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main( ) {
  vector<int> v;
  v.push_back(0);
  v.push_back(1);
  v.push_back(2);
  cout << v.size( ) << endl;
  cout << distance(v.begin( ), v.end( )) << endl;
}

/* 
3
3

 */        
  








Related examples in the same category

1.Get the distance between two element in a list