I am a newbie to C++. So, please bear with me. I was looking into the implementation of the std::vector
class. I found the following 2 different implementation of the begin()
method. I understand that the first one returns a RW iterator and the second one returns a read-only iterator. I thought that mere difference in return type is not enough for function overloading. How does this work then?
iterator
begin()
{ return iterator(this->_M_impl._M_start); }
const_iterator
begin() const
{ return const_iterator(this->_M_impl._M_start); }