I am new to STL maps and vector. I am trying to print the elements present inside the set of vector. The last for-loops are used for printing the elements. The code is given below :
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int arr[]={2,0,2,1,4,3,1,0};
vector<int> v;
set< vector<int> > st;
//set<int> temp;
int init=0,fin=0;
for(int i=0;i<8;++i){
if(find(v.begin(),v.end(),arr[i])==v.end()){//if(temp.find(arr[i])==temp.end()){
v.push_back(arr[i]);//temp.insert(arr[i]);
}
else{
st.insert(v);
v.clear();//temp.clear();
v.push_back(arr[i]);//temp.insert(arr[i]);
}
}
set<vector<int> >::iterator itr;
vector<int>::iterator str;
for(itr=st.begin();itr!=st.end();++itr){
for(str=itr->begin();str!=itr->end();++str){
cout<<*str<<" ";
}
cout<<endl;
}
return 0;
}
The error is:
a.cpp:26:11: error: no viable overloaded '='
for(str=itr->begin();str!=itr->end();++str){
~~~^~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/iterator:1258:7: note: candidate function (the implicit copy assignment operator) not viable: no known conversion from '__wrap_iter<const_pointer>'
to 'const __wrap_iter<int *>' for 1st argument
class __wrap_iter
^
a.cpp:34:2: error: unknown type name 'a'
a.cpp:26:10: error: no viable overloaded '='
^
a.cpp:34:3: error: cannot use dot operator on a type
a.cpp:26:10: error: no viable overloaded '='