I have this simple code:
#include <vector>
class A
{
private:
struct B{int x;};
public:
std::vector<B> v;
};
int main()
{
A a;
for (std::vector<A::B>::iterator it = a.v.begin(); it != a.v.end(); ++it)
{
it->x = 0;
}
for (auto it = a.v.begin(); it != a.v.end(); ++it)
{
it->x = 0;
}
}
As expected I have build error in the first for loop - A::B is private, but second for loop compiles fine in Visual Studio 2010, 2012 and 2013. Is this normal behavior or it's a bug in the compiler?