Suppose you have this very silly code (it's just to make it easy to ask the coming question):
#include <iostream>
class A
{
public:
A() : m(0) {}
void showM1( int m )
{
std::cout << m << std::endl;
}
void showM2()
{
int m = 5;
std::cout << m << std::endl;
}
int m;
};
int main()
{
A a;
a.showM1( 5 );
a.showM2();
}
When I tested, no suprise, it displays 5 and 5. But is this really deterministic? Is the priority ALWAYS given to the local variable (or method parameter) and object attribute comes next?
I'm asking because we renamed some variables in a huge project and just would like to be sure the behaviour is not "undertermined" and could vary on platforms, compilers...
PS: I know this is bad practce and found topics mentioning that the best way is to avoid name conflict (like this one)....