vector::at (STL/CLR)
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at vector::at (STL/CLR).
Accesses an element at a specified position.
Syntax
reference at(size_type pos);
Parameters
pos
Position of element to access.
Remarks
The member function returns a reference to the element of the controlled sequence at position pos
. You use it to read or write an element whose position you know.
Example
// cliext_vector_at.cpp
// compile with: /clr
#include <cliext/vector>
int main()
{
cliext::vector<wchar_t> c1;
c1.push_back(L'a');
c1.push_back(L'b');
c1.push_back(L'c');
// display contents " a b c" using at
for (int i = 0; i < c1.size(); ++i)
System::Console::Write(" {0}", c1.at(i));
System::Console::WriteLine();
// change an entry and redisplay
c1.at(1) = L'x';
for (int i = 0; i < c1.size(); ++i)
System::Console::Write(" {0}", c1[i]);
System::Console::WriteLine();
return (0);
}
a b c
a x c
Requirements
Header: <cliext/vector>
Namespace: cliext