Names for Variables

C++ encourages you to use meaningful names for variables. If a variable represents the cost of a trip, you should call it cost_of_trip or costOfTrip, not just x or cot. You do have to follow a few simple C++ naming rules:

• The only characters you can use in names are alphabetic characters, numeric digits, and the underscore (_) character.

• The first character in a name cannot be a numeric digit.

• Uppercase characters are considered distinct from lowercase characters.

• You can’t use a C++ keyword for a name.

• Names beginning with two underscore characters or with an underscore character followed by an uppercase letter are reserved for use by the implementation—that is, the compiler and the resources it uses. Names beginning ...

Get C++ Primer Plus now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.