N
nvangogh
Suppose I have a vector<int> values. Now the pair values.begin() and
values.end() will cover the range of the vector.
I am writing a simple function that takes the pair of iterators as
arguments along with an int value. The function then returns a bool to
indicate if the int value is found in the vector.
The first problem I have is to question if it is possible to pass
iterators as distinct arguments to a function? I would have thought that
the only way to accomplish this would be to pass the vector as a
reference, from there the function can use the iterators to do it's work.
I was thinking the correct definition would be
bool find_value (vector<int>&, int);
Or is there a way to pass an iterator pair as function arguments which I
have missed?
values.end() will cover the range of the vector.
I am writing a simple function that takes the pair of iterators as
arguments along with an int value. The function then returns a bool to
indicate if the int value is found in the vector.
The first problem I have is to question if it is possible to pass
iterators as distinct arguments to a function? I would have thought that
the only way to accomplish this would be to pass the vector as a
reference, from there the function can use the iterators to do it's work.
I was thinking the correct definition would be
bool find_value (vector<int>&, int);
Or is there a way to pass an iterator pair as function arguments which I
have missed?