N
Nephi Immortal
I have a question. If I declare either const or non-const iterator
object, how do vector constructor know to recognize const or non-
const?
For example:
vector< int > v;
vector< int >::iterator I_B = v.begin();
vector< int >::iterator I_E = v.end();
const vector< int > cv;
vector< int >::const_iterator cI_B = cv.begin();
vector< int >::const_iterator cI_E = cv.end();
Look at the function declaration below.
template<class InputIterator>
vector(
InputIterator _First,
InputIterator _Last
);
I write another vector constructor.
vector< int > v2( I_B, I_E );
const vector< int > cv2( cI_B, cI_E );
How do vector constructor recognize? It sounds like it must have
first version of const constructor function and second version of non-
const constructor function.
object, how do vector constructor know to recognize const or non-
const?
For example:
vector< int > v;
vector< int >::iterator I_B = v.begin();
vector< int >::iterator I_E = v.end();
const vector< int > cv;
vector< int >::const_iterator cI_B = cv.begin();
vector< int >::const_iterator cI_E = cv.end();
Look at the function declaration below.
template<class InputIterator>
vector(
InputIterator _First,
InputIterator _Last
);
I write another vector constructor.
vector< int > v2( I_B, I_E );
const vector< int > cv2( cI_B, cI_E );
How do vector constructor recognize? It sounds like it must have
first version of const constructor function and second version of non-
const constructor function.