I am getting the run time error in following code. Please let me know can i copy vector elements in set?
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
vector<int> v;
set<int> kk;
set<int>::iterator itr;
for (int i = 0; i < 6; i++)
{
v.push_back(i * 2);
}
copy(v.begin(), v.end(), inserter(kk, itr));
}
You are not initialising
itr:Or remove
itrentirely:In this instance, you could simply initialise
kkthus (but if you want to add tokkfollow the line above):