It is well known that there are many keywords in any development language, and different keywords have different uses and functions. As a C++ development engineer, it is necessary to understand and master the function and usage of keywords. So what are the common C++ keywords?

What are the common C++ keywords?

Asm (instruction strings) : allows assembly code to be embedded in C++ programs.

Auto: auto (automatic, automatic) is a storage type identifier that indicates that the variable “auto” has a local scope. Block-scope variable declarations (such as those in the body of the for loop) default to auto.

Bool: bool (Boolean), a basic data structure in C++. The value can be true or false. Bool in C++ can be mixed with int, specifically 0 for false and non-0 for true. The bool type is often used for conditional judgment and function return values.

4, break: break, used in switch statements or loop statements. When the program encounters a break, it skips the program segment and continues the following statement execution.

5. Case: used in switch statements to judge different condition types.

What are the common C++ keywords?

6. Catch: The catch and try statements are used together for exception handling.

7, char: char (character), a basic data structure in C++. The value is usually 0 to 255 int. These 256 characters correspond to 256 ASCII codes. Char data needs to be enclosed in single quotation marks.

8. Class: class is the foundation of C++ object-oriented design. Declare a class using the class keyword.

9, Const. The object or variable that is modified by const (constant, constant) cannot be changed. When modifying a function, the function cannot change variables declared outside the function and cannot call any nonconst functions. Const is always declared and defined after the last parenthesis in the function argument list.

10 and Continue. The continue keyword is used for loop structures. It causes the program to skip the later part of the code segment, and unlike break, continue does not execute after the segment, but instead restarts the loop. So it means “continue the cycle”, not “break out”.

Free C++ learning materials