变量重新定义未发出警告

时间:2019-06-21 10:20:33

标签: c++

我有这段旧代码(修改为可编译),我认为这会为pos上的变量重新定义提供警告,但事实并非如此。谁能告诉我为什么不这样做?

亲切问候

https://www.onlinegdb.com/ByUR079yS

#include <iostream>
#include <vector>

using namespace std;

struct foo
{
    std::vector<int*> bar;
};

int main()
{
    std::vector<foo*> m_ListCilinders;
    for (std::vector<foo*>::iterator pos = m_ListCilinders.begin(); pos != m_ListCilinders.end(); pos++)
    {
        foo* pCilinder = *pos;

        for (std::vector<int*>::const_iterator pos = pCilinder->bar.begin(); pos != pCilinder->bar.end(); pos++)
        {
            int* pLevering = *pos;
        }
    }

    return 0;
}

0 个答案:

没有答案