Rule Definition
Having the same name refer to two different objects can lead to confusion. In case of refactoring, when the code is moved around, a line of code can pick-up a different variable from the one intended. Hiding is also an indication that names may have been poorly chosen, and not informative enough.
Hiding with global names is not checked, because a modification in one part of the code could lead to a violation in another unrelated part.
Remediation
To correct that problem, choose different variable names.
Violation Code Sample
int i;
int main()
{
int i = 3; // Not a violation
int j = 2;
for (int j = 0 ; j<10 ; ++j) // Violation
{
}
}
Reference
High Integrity C++ Coding Standard Manual
Related Technologies
C++
Technical Criterion
Programming Practices - OO Inheritance and Polymorphism
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.