What are legal variable names and declarations in c and c plus plus?

1 answer

Answer

1027748

2026-08-05 06:35

+ Follow

Any name that is not a reserved Word can be a legal variable, function or type name. All names must be alphanumeric, but they cannot begin with a digit. The C++ standard recommends that all user-defined names be written entirely in lower case with underscores for spaces. Some programmers prefer 'camel case' (such as PrintObject and MaxNumber), which was a popular convention amongst the Pascal programming community, however print_object and max_number are the C++ conventions. Names in all caps are typically reserved for macro definitions (which is effectively a separate language from C++ itself), while names with leading underscores should generally be avoided as this convention is utilised extensively within the standard library.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.