In this tutorial, we will be discussing a program to understand output iterators in C++.
Output iterators are a part of the major five iterators. They function opposite of the input iterators in a way that they can be assigned values but can’t be accessed to fetch values.
Example
#include<iostream>
#include<vector>
using namespace std;
int main(){
vector<int>v1 = {1, 2, 3, 4, 5};
//declaring iterator
vector<int>::iterator i1;
for (i1=v1.begin();i1!=v1.end();++i1){
*i1 = 1;
}
return 0;
}Output
No output, because we cannot access values of output operators