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
  • 49,413
  • 29
  • 133
  • 174
Justin
  • 400
  • 1
  • 5
  • 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,383
  • 3
  • 32
  • 53