Inserting into a std::vector at an index via the assignment operator

后端 未结 5 1222
北恋
北恋 2021-01-13 06:17

I\'m new to C++ and am curious if this is the preferred way of inserting into a std::vector

std::vector myVector;

   void setAt(int x         


        
5条回答
  •  隐瞒了意图╮
    2021-01-13 06:59

    It will work in case you are not trying to access it out of its bounds, i.e. vector size is greater than x.

提交回复
热议问题