Naming Conventions
intermediateConsistent naming makes code readable and maintainable.
C++ Naming Conventions
PascalCase: StudentBankAccount, calculateArea
Use for: classes, structs, enums, functions, namespaces
camelCase: studentCount, calculateTotal
Use for: variables, functions, parameters
UPPER_SNAKE_CASE: MAX_SIZE, PI, DEFAULT_TIMEOUT
Use for: constants, macros
snake_case: student_bank_account, calculate_area
Use for: variables, functions (alternative style)
Hungarian Notation: iCount, szName, pPointer
Avoid: redundant with types, hard to read
Examples
Naming Tips
- Be descriptive: studentCount (not sc)
- Use nouns for variables: student, score, index
- Use verbs for functions: calculate, print, validate
- Avoid abbreviations: count (not cnt)
- Be consistent across your project
File Naming
- PascalCase for classes: StudentManager.cpp
- snake_case for utilities: string_utils.cpp
- Match header and source files
Key takeaway: Use PascalCase for types, camelCase for variables, and UPPER_SNAKE_CASE for constants — consistency matters most.
Try it: Rename a small class and its variables to follow PascalCase for types, camelCase for variables, and UPPER_SNAKE_CASE for constants.