| Example | |
| In this example, there are two variable declarations with the same name. This is misleading and can confuse developers. | |
|
| Solution |
|
Instead, name the variable differently so that it is evident which variable is being manipulated. It is recommended that the variable has a meaningful name.
|
|
class ClassA { public: int someFunction() { struct Hat { int sameName; }; Hat myHat; myHat.sameName = 5; int banana = 5; return banana; } }; |