zoukankan      html  css  js  c++  java
  • 低级错误

    #include <vector>
    int main()
    {
        std::vector<int> vecT;
        vecT.push_back(1);
        vecT.push_back(2);
        vecT.push_back(3);
    
        for (std::vector<int>::iterator it = vecT.begin(); it != vecT.end(); ++it)
        {
            while (it != vecT.end())
            {
                ++it;
            }
        }
        return 0;
    }

    我原以为这段小程序没有问题,当while循环退出来的时候it已经是vecT.end()了,而在后面执行的是++it,对vecT.end()执行++直接报错,连最简单的for循环执行顺序都弄错了。闭门思过。

  • 相关阅读:
    实验四
    实验三
    实验二
    实验一
    6
    5
    4
    3
    shiyan2
    实验1
  • 原文地址:https://www.cnblogs.com/zzyoucan/p/4927551.html
Copyright © 2011-2022 走看看