c++ - Do I need to write the `const` keyword when passing a `const_iterator` as argument? -
static void myclassmethod( std::list<aclass> & anobject, const std::list<aclass>::const_iterator & beginningpoint); in code, i'm passing const_iterator of const stl object. feels 1 of constantnesses redundant.
how differ if remove const keyword, or if change const_iterator iterator?
std::list<aclass>::iterator& you can change value through iterator , can change iterator points outside function.
std::list<aclass>::const_iterator& you can't change value through iterator can change iterator points outside function.
const std::list<aclass>::iterator& you can change value through iterator can't change iterator points outside function.
const std::list<aclass>::const_iterator& you can't change value through iterator , can't change iterator points outside function.
take note iterators passed reference. if passed value, first const wouldn't matter much. because changing position of iterator effect local copy.
Comments
Post a Comment