If the code entered a scope and defined a new object with the same name as the object outside, Will the newly defined object be correctly defined?
As following code shows:
class ClassB
{
ClassA* p;
ClassB(ClassA* a)
{
p = NULL;
if (a != NULL)
p = a;
}
};
ClassA x;
if (some condition)
{
ClassB x(x);
// Will x->p be NULL or it will be pointer a?
}
In the if scope, x-> is NULL here or a?
I can see in gcc, it will be NULL. But in VS2015 it seems a.
So my question is that what does the standard says for this part. Thanks a lot.