deque - STL C++

deque<X, A>::deque()

Declaration

template <class X, class A = allocator<X> >
deque<X, A>::deque();

Description

This is the constructor for the complex class template.

Header Include

#include <deque>

Overloads

explicit deque(const Allocator& kxrAlloc);

explicit deque(size_type qSize);

deque(size_type qSize, const Type& kxrEntry);

deque(size_type qSize, const Type& kxrEntry, const Allocator& kxrAlloc);

deque(const deque<X, A>& kqrCopy);

deque(InputIterator qFirst, InputIterator qLast);

deque(InputIterator qFirst, InputIterator qLast, const Allocator& kxrAlloc);

deque(deque<X, A>&& qrrCopy);

Example

#include <iostream>
#include <deque>

int main()
{
	using namespace std;

	// This program demonstrates 3 deque contructors
	deque<int>* qpaDeque[3];

	// Default Contructor: qpaDeque[0]
	deque<int> qDefault;
	qpaDeque[0] = &qDefault;

	// Fill a vector with four 34s: qpaDeque[1]
	deque<int> qFilled(4, 34);
	qpaDeque[1] = &qFilled;

	// Copy constructor : qpaDeque[2]
	deque<int> qCopy(qFilled);
	qpaDeque[2] = &qCopy;

	// Output each of the deques that we contructed
	for (int i = 0; i < 3; ++i) {
		cout << "Deque #" << i << " = ";
		deque<int>::iterator qIter;
		for (qIter = qpaDeque[i]->begin(); qIter != qpaDeque[i]->end(); ++qIter) {
			cout << *qIter << "  ";
		}
		cout << endl;
	}

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

Output

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

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