Comments
Материал из cppreference.com
< cpp
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Комментарии служить своего рода в коде документации. При вставке в программу, они фактически игнорируются компилятором, они предназначены исключительно для использования в качестве записки людей, которые читают исходный код. Хотя конкретные документации не является частью стандарта С + +, существует несколько утилит для разбора комментариев с разными форматами документов.
Original:
Comments serve as a sort of in-code documentation. When inserted into a program, they are effectively ignored by the compiler; they are solely intended to be used as notes by the humans that read source code. Although specific documentation is not part of the C++ standard, several utilities exist that parse comments with different documentation formats.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
[править] Синтаксис
/* comment */
|
(1) | ||||||||
// comment\n
|
(2) | ||||||||
Часто известные как "C-стиль" или "многоканальный" комментарии.
2) Original:
Often known as "C-style" or "multi-line" comments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Часто известные как "C + +-стиль" или "одной линии" комментарии.
Original:
Often known as "C++-style" or "single-line" comments.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] C-стиле
C-стиля комментарии обычно используются для комментариев большие блоки текста, однако, они могут быть использованы для комментариев одиночных линий. Чтобы вставить C-стиле комментарий, просто окружают текст с
/* и */, это приведет к тому, содержание комментария игнорируется компилятором. Хотя это не является частью стандарта С + +, /** и */ часто используется для обозначения документации блоков; это законно, потому что вторая звездочка просто рассматриваются как часть комментария. C-стиля комментарии не могут быть вложенными.Original:
C-style comments are usually used to comment large blocks of text, however, they can be used to comment single lines. To insert a C-style comment, simply surround text with
/* and */; this will cause the contents of the comment to be ignored by the compiler. Although it is not part of the C++ standard, /** and */ are often used to indicate documentation blocks; this is legal because the second asterisk is simply treated as part of the comment. C-style comments cannot be nested.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
C-стиля комментарии часто предпочитают в среде, где C и C + + кода могут быть смешаны, потому что они являются единственной формой комментариев, которые могут быть использованы в стандартном C (до C99).
Original:
C-style comments are often preferred in environments where C and C++ code may be mixed, because they are the only form of comment that can be used in the C standard (prior to C99).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] C + +-стиль
C-стиля комментарии обычно используются, чтобы комментировать отдельные линии, однако, несколько C + +-стиль комментарии могут быть размещены вместе, чтобы сформировать многострочные комментарии. C + +-стиль комментарии сообщить компилятору игнорировать все содержимое между
// и новые линии, что делает их очень полезно.Original:
C-style comments are usually used to to comment single lines, however, multiple C++-style comments can be placed together to form multi-line comments. C++-style comments tell the compiler to ignore all content between
// and a new line, which makes them very useful.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Пример
/* C-style comments can contain multiple lines */ /* or just one */ // C++-style comments can comment one line // or, they can // be strung together int main() { // The below code won't be run // return 1; // The below code will be run return 0; }