2

In addition, identifiers defined outside a function may not begin with an underscore.

Why does this restriction apply only to variables outside of a function? Not sure what purpose this could serve.

herohuyongtao
  • 47,739
  • 25
  • 124
  • 164
Justin
  • 400
  • 1
  • 4
  • 16
  • 1
    Because ones declared in a function would shadow those. It shouldn't just be out of functions, though. You can still do it with class members etc. – chris Feb 22 '14 at 06:08

1 Answers1

1

Related question: What are the rules about using an underscore in a C++ identifier?

Short answer: in order to avoid name collision with the standard libraries (e.g. STL, libc, etc.)

Community
  • 1
  • 1
Denis Itskovich
  • 4,093
  • 3
  • 29
  • 50