search

Home  >  Q&A  >  body text

c++ - vector的迭代器能不能用for循环访问??

ringa_leeringa_lee2804 days ago946

reply all(3)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 14:32:24

    If your count is equal to xxx.size(), there is no big difference and it is not unsafe. But the question is why would you do this? Either just use xxx.at(i) to access without iterator; or just use iterator to access

    reply
    0
  • 阿神

    阿神2017-04-17 14:32:24

    Isn’t it better to use it != xxx.end() to control it directly? There is no need to define a new variable count to operate

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 14:32:24

    How about a range for loop or iterator?

    reply
    0
  • Cancelreply