object - variables declaration with same name C++ -


is allowed?

class a{ ... ... };  a; //global object  int main() {    a; // local object    .    .    .    .    return 0; } 

here global object has been declared after class definition, local variable has been declared. ok? why?

it's legal "hide" declaration of object, declaration in tighter scope. within main function, a refer local variable. outside main function, a refer global variable.

as whether it's "ok" - "no". it's bad idea, in it's make code confusing, , more prone accidentally introducing bugs. wouldn't advise doing it.


Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -