Tokens in C++: Keywords
WHAT ARE KEYWORDS?
Keywords are tokens which hold special meaning to the compiler. This means that these words cannot be used to name variables, functions and methods. Keywords stand for a special purpose, and they command the compiler to take action, such as create variables of a certain type, utilize memory capabilities, create structured data, etc.
The keywords being used in C++ are as follows:
- asm: The asm keyword is used to declare that a block of code is to be passed to the assembler.
- auto: auto is a storage class specifier that is primarily used to define objects in a code block.
- break: The break keyword terminates a switch statement or a loop.
- case: The case keyword is used specifically within a switch statement to specify a match for the statement's expression.
- catch: The catch keyword specifies actions when an exception occurs.
- char: char is a fundamental data type, which defines character objects.
- class: The keyword class is used to declare a user-defined type that encapsulates data members and operations or member functions.
- const: const is used to define objects whose value will not alter throughout the lifetime of program execution.
- continue: The continue keyword is used in loops, and it transfers the control to the start of the loop or returns the control to the condition.
- default: Used alongside the switch statement, the default keyword is used to handle a case when none of the other conditions are met.
- delete: delete is the memory deallocation keyword, used to free allocated memory.
- do: The do is one part of the do-while loop, where the keyword indicates the start of the loop execution, and the hook where the point of execution is transferred while a condition is satisfied.
- double: double is a fundamental data type used to define a floating point number (number with decimal point).
- else: else is one of the keywords used in the if-else conditional block. This keyword is the hook where the flow of execution is transferred in the situation where the condition is not satisfied.
- enum: The enum keyword is used to declare a user-defined enumeration data type.
- extern: The extern keyword is used alongside other identifiers to indicate external linkages to the block of code.
- float: The float is a fundamental data type, used to define a class of floating point numbers (numbers with decimal points).
- for: for is an over-utilized keyword, used as a hook which defines a block which undergoes repetitive execution until the recurring condition fails to satisfy a control condition.
- friend: The friend keyword is used with classes to qualify them as a 'friend' for another class, and thus a reliable entity to share private variables, methods and data.
- goto: The goto keyword is used to transfer control to a specified label.
- if: if is one of two keywords of the if-else conditional block. It is the hook where the flow of execution is transferred when the encapsulated condition is met.
- inline: The inline keyword is a function specifier that indicates the compiler that if any code block is present for replacement, that piece of code is given precedence over the function body.
- int: int is a fundamental data type used to define integer objects.
- long: long is a data type modifier that defines a 32-bit int or an extended double.
- new: new is the memory allocation operator.
- operator: The operator is a unique keyword, used to overload a C++ operator with a new declaration.
- private: The private keyword is one of three access modifier, which is used to mask class members from public visibility and access.
- protected: The protected keyword is another of the three access modifier, used to provide partial protection to class members. Members under protected can only be accessed outside the scope of the class by the classes which have derived or inherited the parent class.
- public: The public keyword is the last access modifier, which allows the members to be openly accessed outside the scope of the class itself.
- register: register is a storage class specifier, which is auto-used by the program, and thus seldom used in programming. However, when used, it is used to indicate to the compiler that a particular object is to be used frequently in a program, and hence is to be stored in a easy-access register.
- return: The return keyword is used as a flow-transfer operator. This keyword is used to return the flow of execution to the function caller, i.e., the execution path. Usually return carries with it a value baggage, which it needs to deliver as a process obligation to the function caller.
- short: short is a data type modifier, which is used to define a 16-bit integer.
- signed: The use of signed with other declarative keywords instructs the compiler to save the signature of the object in a higher-order bit.
- sizeof: The sizeof keyword is used to return the size of objects and variables.
- static: The static keyword is a data-type modifier, used to indicate to the compiler that during the lifetime of program execution, the value stored in the object during its initialization, will not be changed. In other words, static modifies a data object into read-only.
- struct: The struct is a user-definable data-type, where a collection of variables of dissimilar predefined data types can be created. struct is used in advanced C++ programs, and requires developers to have a firm grasp on function flows and execution methodologies.
- switch: The switch keyword is the pivotal keyword which is used to trigger the switch process flow. switch initiates the flow if a specified case is specified.
- template: The template keyword is used to create a template of code, which can be used for multiple data types and reused without change of data declarations.
- this: this keyword is used by members of a class to refer to an instance of itself.
- throw: The throw keyword is used to address and display exceptions encountered while trying to execute a piece of code.
- try: The try keyword indicates the hook where the flow of execution will pass on to, and the condition or code stated inside the block is executed. If there are any exceptions and failures endured during this execution, the flow is transferred to the catch block.
- typedef: The keyword typedef is used to rename existing datatypes, both predefined and user defined.
- union: union is a user-definable data-type, similar to struct. However, the major difference between them is the fact that union can only hold one of its member variables in every instance of initialization. This is preferred in executions where allocated memory space takes precedence over accessibility.
- unsigned: The unsigned is a data-type modifier, which indicates that the high-order bit is to be used for an object.
- virtual: The virtual keyword is used in classes to define functions and methods in a class which can be redefined to its need by classes inheriting the parent class.
- void: void is a process enhancement keyword which informs the compiler that no return value is to be expected from the called function, method or class. void is not a data type, but only a process enhancer.
- volatile: The volatile keyword is used to enhance a declared datatype, by informing the compiler that the value of the variable may change without being detected by the compiler.
- while: The while keyword is one of the two keywords words in the do-while loop. This keyword acts like an anchor which checks the sanity of a condition, and if the condition is satisfied, the code under the do block is executed.
Comments
Post a Comment