- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the rules about using an underscore in a C++ identifier?
From MSDN docs −
Use of two sequential underscore characters ( __ ) at the beginning of an identifier, or a single leading underscore followed by a capital letter, is reserved for C++ implementations in all scopes. You should avoid using one leading underscore followed by a lowercase letter for names with file scope because of possible conflicts with current or future reserved identifiers.
So you should avoid using names like −
__foo, __FOO, _FOO
And names like the following should not be used in the global namespace −
Other than this, there are some more prefixes like LC_, SIG_, and suffixes like _t should not be used as they're also reserved for the implementation.
So you can create variables that contain the underscore between the name or ends with an underscore.
- What is an identifier and its rules in C language?
- What is an identifier in C language?
- What are the principles of security identifier?
- What are the rules to declare variables in C++?
- What are the rules for naming classes in C#?
- What are the basic rules for defining variables in C++?
- What are the scope rules to functions in C programming?
- What are the differences between lodash and underscore?
- What are the rules for writing the symbol of an element?
- What are the rules to be followed while using varargs in java?
- What are the rules for calling the superclass constructor C++?
- What are the local and global scope rules in C language?
- __func__ identifier in C
- What are the rules for private methods in an interface in Java 9?
- Write about Mergers & Acquisition percentage rules