deque - STL C++

deque<X, A>::iterator

Declaration

typedef (unspecified) deque<X, A>::iterator;

Description

This is a type definition of the data type iterator for the deque class template. This type is used to sequentially access elements of the deque container.

Header Include

#include <deque>

Example

#include <iostream>
#include <deque>

int main()
{
	using namespace std;

	// Create a deque and add four elements to it
	deque<int> qDeque;
	qDeque.push_back(5);
	qDeque.push_back(101);
	qDeque.push_back(-4);
	qDeque.push_back(32);

	// Use the iterator to access and output the elements
	deque<int>::iterator qIter;
	for (qIter = qDeque.begin(); qIter != qDeque.end(); ++qIter) {
		cout << "Deque entry = " << *qIter << endl;
		// Set the entry to 30 and output it again
		*qIter = 30;
		cout << "Deque entry after it is set = " << *qIter << endl;
	}

	// Keep the window open
	cin.get();
	return 0;
}

Output

deque<X, A>::iterator Output
 

© 2007–2024 XoaX.net LLC. All rights reserved.