V.at(i) is same as V[i]
so it fails in your case because you are trying to use at() with iterator,which is wrong.
at() function expects an integer input, which is the index of the element we intend to access.
consider the code below:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int>v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);
cout<<"indexed output: "<<v[1]<<"\n";
cout<<"output using at: "<<v.at(2)<<"\n";
}
output is:
indexed output: 2
output using at: 3
from this we can observe that using at() is same as indexed access.
Iterator works similar to pointer,hence you can write
cout<<*it