Having problems with iterators & vectors

Can't work out what is the problem here:
I get this error:
1
2
codeBuildsFine.cpp:11:9: error: no match for 'operator=' (operand types are 'std::vector<int>' and '<brace-enclosed initializer list>')

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  #include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main()
{
    vector<int> vecList;
 ostream_iterator<int> screen(cout, " ");
vecList = {12, 16, 8, 23, 40, 6, 18, 9, 75};
copy(vecList.begin() + 2, vecList.end(), screen);
cout << endl;
}


Update your compiler to c++11 or later.
Last edited on
Topic archived. No new replies allowed.