Basic Elements of C++ Language

- November 17, 2017
In this article we discuss about the basic elements of C++ programming language. It is best practice to remember all these elements before starting programming with C++. Here you will find a complete list of C++ keywords, information about C++ identifiers, character set of C++ and tokens. All these mentioned elements are much important to getting started with C++. So let's start the topic "Basic elements of C++ programming language."

What are Keywords of C++ Language

The predefined words of the C++ that are used for special purpose in the source program are called keywords. Keywords are also known as reserved words.
      Each keyword has certain meaning in C++ programming language. The purpose and its meaning of every keyword defined by the developer of this language. These can't redefined or use in other ways such as function names or variables name in source code. For example, we can't use "int" as a function name or variable name in program. It is because, "int" is a keyword that is used to define intger type variables.
      In C++ programming language, there are 64 keywords that are used for various purposes. Each keyword has its own value in the source code and used for specific function. A complete list of C++ keywords are given below:-
  1. int
  2. if
  3. inline
  4. long
  5. goto
  6. mutable
  7. namespace
  8. friend
  9. for
  10. float
  11. false
  12. extern
  13. export
  14. explicit
  15. enum
  16. else
  17. ast
  18. default
  19. delete
  20. do
  21. double
  22. dynamic_c
  23. catch
  24. char
  25. class
  26. const
  27. const_cast
  28. continue
  29. asm
  30. auto
  31. bool
  32. break
  33. case
  34. new
  35. operator
  36. private
  37. protected
  38. public
  39. register
  40. reinterpret_cast
  41. sizeof
  42. signed
  43. short
  44. return
  45. static
  46. this
  47. typeid
  48. virtual
  49. static_cast
  50. throw
  51. typename
  52. void
  53. struct
  54. true
  55. union
  56. volatile
  57. switch
  58. try
  59. unsigned
  60. wchar_t
  61. template
  62. typedef
  63. using
  64. while

Character set of C++ Language

      Like other programming language, C++ also has a set of characters. These characters are used to write the statements and defining variables of the source code. These characters are known as character set or alphabet of C++ language. A complete list of alphabets of C++ are given below.

Lowercase letters

a b c d e f g h I j k l m n o p q r s t u v w x y z

Uppercase letters

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Special Characters


+ - / = ( ) { } [ ] < > ` " ! @ # $ % \ / ; ? % € £ ¥ ₩ & ~ ^ * 

Digits


0 1 2 3 4 5 6 7 8 9 

White spaces


Blanks, new line, tab etc.

What are Identifiers in C++ Language

The unique names used in source code to represents functions, variables, labels and constants etc are called identifiers. 
      In C++ programming language, an identifier name may consists of 31 characters. If the name of identifier is more than 31 characters, than only first thirty one characters will be used by C++ compiler and others will be ignored. 
Following are the rules to give the name to an identifier:-
  • The first character of an identifier must be an alphabetic letter or underscore. 
  • We can't use any keyword as identifier name.
  • An identifier name may consist on alphabets, underscore or digits. 

Types of Identifiers

There are two types of identifiers in C++ languages.
  1. Standard identifier
  2. User defined identifier 


What are Tokens in C++

"A source code consists on different elements such as keywords, constant, punctuators, variables and operators etc. These elements of a program are known as tokens."
To understand it better look at given below the source code:
  1. #include <iostream.h>
  2. main ()
  3. {
  4. float temp, xy;
  5. xy = 30;
  6. temp = xy+10*5;
  7. }


In the above mentioned code:-

  • The "float" is a keyword. 
  • The "main" is a special identifier.
  • The "temp" and "xy" are variables. 
  • The punctuators are: { } ; , ( ) and white space etc.
  • The operators are: = * + / % > < etc.