vector - STL C++

vector<X, A>::at()

Declaration

reference vector<X,A>::at(size_type qIndex);

Description

This is the at() function for the vector class template.

Header Include

#include <vector>

Overloads

const_reference vector<X,A>::at(size_type qIndex) const;

Example

#include <iostream>
#include <vector>

int main()
{
	using namespace std;

	// Create a vector instance
	vector<int> qV;
	qV.push_back(3);
	qV.push_back(4);

	int& irIntRef = qV.at(0);
	const int& kirConstIntRef = qV.at(1);

	cout << "V[0] = " << irIntRef << endl;
	cout << "V[1] = " << kirConstIntRef << endl;

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

Output

vector<X, A>::at() Output
 

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