0% found this document useful (0 votes)
22 views

C++ 07 Identifiers

The document discusses C++ identifiers which are unique names used to identify variables in C++. Identifiers can use letters, digits, and underscores and must begin with a letter or underscore. Identifiers are case sensitive, cannot contain spaces or special characters, and cannot use reserved words. The document provides an example of a good descriptive identifier versus a less clear one.

Uploaded by

erik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

C++ 07 Identifiers

The document discusses C++ identifiers which are unique names used to identify variables in C++. Identifiers can use letters, digits, and underscores and must begin with a letter or underscore. Identifiers are case sensitive, cannot contain spaces or special characters, and cannot use reserved words. The document provides an example of a good descriptive identifier versus a less clear one.

Uploaded by

erik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1/28/24, 9:49 PM C++ Identifiers

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

Ads by
Stop seeing this ad Why this ad?

C++ Identifiers
❮ Previous Next ❯

C++ Identifiers
All C++ variables must be identified with unique names.

These unique names are called identifiers.

Identifiers can be short names (like x and y) or more descriptive names (age, sum,
totalVolume).

Note: It is recommended to use descriptive names in order to create understandable


and maintainable code:

Example

// Good
int minutesPerHour = 60;

// OK, but not so easy to understand what m actually is


int m = 60;

Try it Yourself »

The general rules for naming variables are:

https://www.w3schools.com/cpp/cpp_variables_identifiers.asp 1/4
1/28/24, 9:49 PM C++ Identifiers

Names can contain letters, digits and underscores


 Tutorials
Names must Exercises
 begin Services
with a letter 
or an underscore (_) Sign Up Log in
Names are case sensitive ( myVar and myvar are different variables)
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C
Names cannot contain whitespaces or special characters like !, #, %, etc.
Reserved words (like C++ keywords, such as int ) cannot be used as names

❮ Previous Log in to track progress Next ❯

ADVERTISEMENT

Ads by

Stop seeing this


ad

Why this ad?

https://www.w3schools.com/cpp/cpp_variables_identifiers.asp 2/4
1/28/24, 9:49 PM C++ Identifiers

 Tutorials  Exercises  Services   Sign Up Log in

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C

COLOR PICKER



ADVERTISEMENT ADVERTISEMENT

 SPACES UPGRADE AD-FREE

NEWSLETTER GET CERTIFIED REPORT ERROR

Top Tutorials Top References


HTML Tutorial HTML Reference
CSS Tutorial CSS Reference
JavaScript Tutorial JavaScript Reference

https://www.w3schools.com/cpp/cpp_variables_identifiers.asp 3/4
1/28/24, 9:49 PM C++ Identifiers
How To Tutorial SQL Reference

 SQL Tutorial
Tutorials  Exercises 
Python Tutorial
W3.CSS Tutorial
Services  Python Reference

W3.CSS Reference
Bootstrap Reference
Sign Up Log in

HTML
 CSS Bootstrap Tutorial
JAVASCRIPT SQL PYTHON PHP ReferencePHP
JAVA HOW TO W3.CSS C
PHP Tutorial HTML Colors
Java Tutorial Java Reference
C++ Tutorial Angular Reference
jQuery Tutorial jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
W3.CSS Examples PHP Certificate
Bootstrap Examples jQuery Certificate
PHP Examples Java Certificate
Java Examples C++ Certificate
XML Examples C# Certificate
jQuery Examples XML Certificate

    FORUM ABOUT
W3Schools is optimized for learning and training. Examples might be simplified to
improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we
cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of
use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by


W3.CSS.

https://www.w3schools.com/cpp/cpp_variables_identifiers.asp 4/4

You might also like