C++: Incrémenter la position d’un itérateur avec l’opérateur ‘++’

Author:

 list, assert, list
Download


#include 
#include 
#include

#include 
using namespace std;

int main()
{

  char x[6] = {'B', 'O', 'N', 'J', 'U','R'};

  list list1(x, x+5);

  // Rechercher la position de N
  list::iterator where = find(list1.begin(), list1.end(), 'N');

  list::iterator next = where;
  ++next; //Incrémenter la position

  //Afficher le caractère suivant
  cout << *next << endl;
  return 0;
}

 /*
J
 */       

Leave a Reply

Your email address will not be published. Required fields are marked *