vector - STL C++

vector<X, A>::const_reference

Declaration

typedef const X& vector<X, A>::const_reference;

Description

This is a type definition of the data type const_reference for the vector class template. This type is used to reference elements in the container without changing them.

Header Include

#include <vector>

Example

#include <iostream>
#include <vector>

int main()
{
	using namespace std;

	// Create a vector and add an element to it
	vector<int> qVector;
	qVector.push_back(5);

	// Assign a reference and output the element
	vector<int>::const_iterator qIter = qVector.begin();
	vector<int>::const_reference qRef = (*qIter);
	cout << "qRef refers to " << qRef << endl;

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

Output

vector<X, A>::const_reference Output
 

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