In a const member function, the member data are const too. So you need to use const_iterator
:
typename Mytype::const_iterator it = myarg.begin();
because myarg.begin()
returns const iterator, because myarg
is const, because member function is const.
Even better use auto
:
auto it = myarg.begin();
But then you still need to know it
is const — auto
helps you to avoid typing the long name, not knowing the fact that it
is const.