deque - STL C++

deque<X, A>::operator[]()

Declaration

reference deque<X,A>::operator[](size_type qIndex);

Description

This is the operator[]() function for the deque class template.

Header Include

#include <deque>

Overloads

const_reference deque<X,A>::operator[](size_type qIndex) const;

Example

#include <iostream>
#include <deque>

int main()
{
	using namespace std;

	// Create a deque instance
	deque<char> qD;
	qD.push_back('X');
	qD.push_back('o');
	qD.push_back('a');
	qD.push_back('X');
	qD.push_back('.');
	qD.push_back('n');
	qD.push_back('e');
	qD.push_back('t');

	// Use the array operator to access elements
	for (int iIndex = 0; iIndex < 8; ++iIndex) {
		cout << qD[iIndex];
	}
	cout << endl;

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

Output

deque<X, A>::operator[]() Output
 

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