Roughly speaking in C++ there are operators (+ , - * [] new ...)
, identifiers (names of classes, variables, functions,...), const literals (10, 2.5, "100",...)
, some keywords (int, class, typename, mutable, ...)
, brackets ({ } < > )
, preprocessor (#, ## ...)
. But what is the semicolon?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Semicolon is a statement terminator.
The semicolon lets the compiler know that it's reached the end of a command AFAIK.
If I recall correctly, Kernighan and Ritchie called it punctuation. Technically, it's just a token (or terminal, in compiler-speak), which can occur in specific places in the grammar, with a specific semantics in the language. The distinction between operators and other punctuation is somewhat artificial, but useful in the context of C or C++, since some tokens (
,
,=
and:
) can be either operators or punctuation, depending on context, e.g.:In the case of the first two, the distinction is important, since a user defined overload will only affect the operator, not punctuation.
It represents the end of a C++ statement.
For example,
In the above code there are two statements. The first is for declaring the variable and the second one is for incrementing the value of variable by one.
The semicolon (;) is a command in C++. It tells the compiler that you're at the end of a command.