Public Group

This topic is 4252 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

std::vector<int> v; std::advance(v.begin(),v.end()); compile tell me: error C2664: 'advance' : cannot convert parameter 1 from 'char ** ' to 'char **& ' A reference that is not to 'const' cannot be bound to a non-lvalue it is strang. how to solve it?

##### Share on other sites
v.end() returns an iterator. std::advance takes integral type as its 2nd paramater not an iterator
	std::vector<int> v;	v.push_back(5);	v.push_back(67);	std::advance((v.begin()),1);

works here.

if you are hoping to increment the iterator returned by begin(), you must realize that you are getting a copy back from this fn. So the above code really does nothing as the result is lost right after the function call.

Docs that might help.
Vector

##### Share on other sites
You are not using the function correctly. The first parameter is an iterator whose value you want to change. The second parameter is an integer value that tells how many times to increment the first parameter.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633661
• Total Posts
3013225
×