我有这段旧代码(修改为可编译),我认为这会为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;
}