no match for 'operator=' for vector iterator

Solving below problem and getting error:
Problem statement:
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
Error :
error: no match for 'operator=' (operand types are 'std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}' and '__gnu_cxx::__normal_iterator<const int*, std::vector<int> >')
it = A.begin() + a;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
int GetMaxSum(vector<int> V)
{
	vector<int>::iterator it;

	int n = V.size();
	int a = 0;
	int s = 0;

	while (a < n)
	{
		int sum = 0;
		int temp = 0;
		it = V.begin() + a;
		for (int i = 0; i < (n-a); i++)
		{
			temp = temp + (*it);
			sum = ((sum > temp) ? sum : temp);
			it++;
		}

		s = ((s < sum) ? sum : s);
		a++;
	}

	return s;
}


NOTE : I know this is not a best solution as time complexity is n*n.
I am trying to solve it in better time complexity.

Error gone when define const iterator instead normal iterator.
i.e.
 
vector<int>::const_iterator it;


I am still not sure why it needed const iterator.
Would any one like reply here...? :)
I am not getting this error on all c++ compilers.
e.g. on c++ 11 I am gcc(4.8) I am getting this error.

But When I ran this same code on VS 2015 with latest compiler, code compiled successfully.
> I am not getting this error on all c++ compilers.

There is no error in the posted code even with g++-4.8 (4.8.1)
http://coliru.stacked-crooked.com/a/cb25fa2c977fd522

Ideally, avoid versions of the GNU compiler/library older than GCC 5.1
Topic archived. No new replies allowed.