Maison  >  Questions et réponses  >  le corps du texte

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

ringa_leeringa_lee2717 Il y a quelques jours875

répondre à tous(3)je répondrai

  • PHP中文网

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

    如果你的count等于xxx.size(),没啥大区别,也不会不安全。但问题是你干嘛要这样做呢?要么就只用xxx.at(i)来访问不用iterator;要么纯用iterator来访问

    répondre
    0
  • 阿神

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

    直接用it != xxx.end()来控制不是更好,不必再定义新的变量count来操作

    répondre
    0
  • 伊谢尔伦

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

    要不就范围for循环或者迭代器?

    répondre
    0
  • Annulerrépondre