Can We Replace value of vector element using Iterator?
<p>How Iterators actually work in vectors.If we need to replace a data element in vector, can we proceed through iterator or do we need some other kind of implementation to do so?</p>

<p>Following is my code for above Query </p>

<pre><code>#include &lt;bits/stdc++.h&gt;
using namespace std;
vector &lt;string&gt; v;
vector &lt;string&gt; :: iterator it;
int main()
{
    int t,l,i;
    cin &gt;&gt; t;
    for(i=0;i&lt;t;i++){
        string s;
        cin &gt;&gt; s;
        v.push_back(s);
    }
    string s2="replaceable String";
    //Now I want to change some string at index i in vector v to string s2
    for(it=v.begin();it!=v.end();it++){
        cout &lt;&lt; *it &lt;&lt; endl;
    }
    return 0;
}
</code></pre>