Declaring a local variable within class scope with same name as a class attribute
问题 While observing another person's code, i realized that within class A's method he declared a local int with the same name as an attribute of class A. For example: //classA.h class A{ int Data; void MethodA(); }; //classA.cpp #include "classA.h" using namespace std; void A::MethodA(){ int Data; //local variable has same name as class attribute Data = 4; //Rest of Code } I found it weird that the compiler would accept it without returning an error. In the above case, would the 4 be assigned to