Pointers to elements of std::vector and std::list

后端 未结 7 892
借酒劲吻你
借酒劲吻你 2020-12-05 06:56

I\'m having a std::vector with elements of some class ClassA. Additionally I want to create an index using a std::map

7条回答
  •  庸人自扰
    2020-12-05 07:28

    1. for vectors no.
    2. for lists yes. how? iterator works as a pointer to a particular node in the list. so you can assign values to any struct like:

      list mylist;

      pair< list::iterator ,int > temp;

      temp = make_pair( mylist.begin() , x );

提交回复
热议问题