c++ - how does overloading of const and non-const functions work? -
the stl full of definitions this:
iterator begin (); const_iterator begin () const;
as return value not participate in overloading resolution, difference here function being const
. part of overloading mechanism? compiler's algorithm resolving line like:
vector<int>::const_iterator = myvector.begin();
in example gave:
vector<int>::const_iterator = myvector.begin();
if myvector
isn't const non-const version of begin()
called , relying on implicit conversion iterator const_iterator.
Comments
Post a Comment