Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Erases a array and copies the specified elements to the empty array.
void fill(
const Type& _Val
);
Parameters
Parameter |
Description |
_Val |
The value of the element being inserted into the array. |
Remarks
fill replaces each element of the array with the specified value.
Example
// array_fill.cpp
// compile with: /EHsc
#include <array>
#include <iostream>
int main( )
{
using namespace std;
array<int, 2> v1 = {1, 2};
array<int, 2>::iterator iter;
cout << "v1 = " ;
for (iter = v1.begin(); iter != v1.end(); iter++)
cout << *iter << " ";
cout << endl;
v1.fill(3);
cout << "v1 = " ;
for (iter = v1.begin(); iter != v1.end(); iter++)
cout << *iter << " ";
cout << endl;
}
Output
v1 = 1 2
v1 = 3 3
Requirements
Header: <array>
Namespace: std