C++ Language
Reserved Keywords
Reserved keywords are words that have special meaning and are reserved for specific purposes. These keywords cannot be used as identifiers (names for variables, functions, classes, etc.) because they are already used by the language for specific tasks. Here's a list of reserved keywords in C++:
- asm
- auto
- break
- case
- catch
- char
- class
- const
- continue
- default
- delete
- do
- double
- else
- enum
- extern
- float
- for
- friend
- goto
- if
- inline
- int
- long
- new
- operator
- private
- protected
- public
- register
- return
- short
- signed
- sizeof
- static
- struct
- switch
- template
- this
- throw
- try
- typedef
- union
- unsigned
- virtual
- void
- volatile
- while
asm | auto | break | case | catch |
char | class | const | continue | default |
delete | do | double | else | enum |
extern | float | for | friend | goto |
if | inline | int | long | new |
operator | private | protected | public | register |
return | short | signed | sizeof | static |
struct | switch | template | this | throw |
try | typedef | union | unsigned | virtual |
void | volatile | while |
Note: Please note that some keywords, like 'char8_t', 'char16_t', and 'char32_t' are introduced for Unicode character types in C++11. The list may be subject to changes with new C++ standards.
• Essential keywords with their meanings:
'asm': To declare that a block-of-code is to be passed to the assembler.
'auto': Specifies automatic type deduction for variables declared with it.
'break': Used to terminate a loop or switch statement.
'case': Used in a switch statement to define different possible values.
'catch': Specifies actions taken when an exception occurs.
'char': Declares a character type.
'class': Declares a class in object-oriented programming.
'const': Specifies that a variable's value cannot be changed.
'continue': Jumps to the next iteration of a loop.
'default': Specifies the default case in a switch statement.
'delete': Used to deallocate memory that was previously allocated with 'new'.
'do': Initiates a do-while loop.
'double': Declares a double-precision floating-point type.
'else': Used in conjunction with if statements to specify the code to execute when the condition is false.
'enum': Declares an enumeration type.
'extern': Declares that a variable or function is defined elsewhere.
'float': Declares a floating-point type.
'for': Initiates a for loop.
'friend': Declares a function or class as a friend, allowing it to access private members of another class.
'goto': Transfer control to a specified label..
'if': Initiates an if statement.
'inline': Suggests the compiler to insert the code of the function into the calling code rather than generating a function call.
'int': Declares an integer type.
'long': Declares a long integer type.
'new': Allocates memory for an object or an array.
'operator': Declares an operator function.
'private': Specifies that class members declared as private are accessible only within the same class.
'protected': Specifies that class members declared as protected are accessible within the same class and its subclasses.
'public': Specifies that class members declared as public are accessible from anywhere.
'register': Suggests to the compiler that a variable should be stored in a register.
'return': Specifies the return value of a function.
'short': Declares a short integer type.
'signed': Declares a signed integer type.
'sizeof': Returns the size, in bytes, of a type or an object.
'static': Specifies that a variable or function is static, meaning it has a single instance shared by all instances of the class or function.
'struct': Declares a structure, a composite data type.
'switch': Initiates a switch statement.
'template': Declares a template, a way to write generic code.
'this': A pointer that points to the object for which the member function is called.
'throw': Signals that an exception has occurred.
'try': Initiates a block of code that may throw an exception.
'typedef': Creates a type alias.
'union': Declares a union, a type that can hold different data types but only one at a time.
'unsigned': Declares an unsigned integer type.
'virtual': Specifies that a function can be overridden in derived classes.
'void': Specifies that a function does not return a value or that a pointer does not point to any type.
'volatile': Indicates that a variable may be changed by multiple threads or asynchronously.
'while': Start of a while statement and end of a do-while statement.
These keywords are fundamental to writing C++ code, and understanding their usage is crucial for developing effective and efficient programs.
What's Next?
We've now entered the finance section on this platform, where you can enhance your financial literacy.