deque - STL C++

deque<X, A>::operator=()

Declaration

deque<X,A>& deque<X,A>::operator=(const deque<X,A>& kqrDeque);

Description

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

Header Include

#include <deque>

Overloads

deque<X,A>& deque<X,A>::operator=(deque<X,A>&& qrrDeque);

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');

	deque<char> qCopy;
	qCopy.push_back('A');
	qCopy.push_back('B');
	qCopy.push_back('C');

	// Output the deque before the assignment
	deque<char>::iterator qIter;
	cout << "Deque before = ";
	for (qIter = qCopy.begin(); qIter != qCopy.end(); ++qIter) {
		cout << *qIter;
	}
	cout << endl;

	cout << "Copy the deque with the assignment operator" << endl;
	qCopy = qD;

	// Output the deque after the assignment
	cout << "Deque after = ";
	for (qIter = qCopy.begin(); qIter != qCopy.end(); ++qIter) {
		cout << *qIter;
	}
	cout << endl;

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

Output

deque<X, A>::operator=() Output
 

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