C++ iterator to const_iterator

后端 未结 2 1235
别那么骄傲
别那么骄傲 2020-12-18 18:55

How do I acquire a const_iterator (of some container class) from an iterator (of that container class) in C++? What about a const_iterator

2条回答
  •  星月不相逢
    2020-12-18 19:23

    You can convert them. Example:

    std::vector v;
    std::vector::iterator it = v.begin();
    std::vector::const_iterator cit = it;
    

    But I guess that is not the answer you are seeking. Show me code. :-)

提交回复
热议问题