C++ allows many naming styles
camelCase
- Description: The first word starts with a lowercase letter; each following word begins with an uppercase letter.
- Usage: Common for variable names and function names in many C++ codebases.
- Example:
myVariableName, processInputData()
PascalCase
- Description: Every word, including the first one, starts with an uppercase letter.
- Usage: Often used for class names, type names, or namespaces.
- Example:
MyClass, FileManager, MathUtilities
snake_case
- Description: All characters are lowercase; words are separated by underscores.
- Usage: Popular in C, some C++ libraries, and Unix-style code.
- Example:
my_variable_name, read_from_file()
SCREAMING_SNAKE_CASE
- Description: Like snake_case, but all letters are uppercase.
- Usage: Common for constants, macros, and global configuration values.
- Example:
BUFFER_SIZE, MAX_CONNECTIONS
kebab-case (rare in C++)
- Description: Words are lowercase and separated by hyphens.
- Usage: Not valid for C++ identifiers; appears mostly in filenames, documentation, or some configuration formats.
- Example:
config-file-path, user-profile-data.json
lowercase (flat lowercase name)
- Description: All lowercase letters, no separators.
- Usage: Often used for short utility variables, iterators, and simple functions.
- Example:
i, count, open
UPPERCASE (flat uppercase name)
- Description: All uppercase letters, no separators.
- Usage: Rare in code; occasionally used for macros or constants.
- Example:
DEBUG
Hungarian notation (mixed, historically common)
- Description: Prefix encodes type or meaning; name encodes identity.
- Usage: Common in older Windows/C++ codebases; less popular today.
- Example:
strName, pItem, iCount
(str = string, p = pointer, i = int)
StudlyCaps / camelCaseWithoutMeaningfulRules (informal)
- Description: Random capitalization pattern; not recommended.
- Example:
DoSomethingCool, myVaRiAbLe