How can I expose iterators without exposing the container used?

前端 未结 4 1124
野性不改
野性不改 2020-12-24 08:14

I have been using C# for a while now, and going back to C++ is a headache. I am trying to get some of my practices from C# with me to C++, but I am finding some resistance a

4条回答
  •  無奈伤痛
    2020-12-24 09:10

    This should do what you want:

    typedef typename std::vector::iterator MyIterator;
    

    From Accelerated C++:

    Whenever you have a type, such as vector, that depends on a template parameter, and you want to use a member of that type, such as size_type, that is itself a type, you must precede the entire name by typename to let the implementation know to treat the name as a type.

提交回复
热议问题