![]() |
VOOZH | about |
Identifiers in C++ are user-defined names used to represent program elements such as variables, functions, classes, and objects. They provide a way to uniquely refer to different entities within a program.
90
This program demonstrates the use of different identifiers in C++, including a class (Student), method (show), variable (marks), object (s1), and function (main). When executed, it creates a Student object and displays the value of the marks variable.
We can use any word as an identifier as long as it follows the following rules:
Additionally, C++ is a case-sensitive language so the identifier such as Num and num are treated as different. The images below show some valid and invalid C++ identifiers.
Example: Valid and Invalid Identifiers in C++
Total: 25
In this example, identifiers are used according to C++ naming rules in variables, class and function.