Comments
Da cppreference.com.
< cpp
![]() |
Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate.
La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Commenti servire come una sorta di in-codice documentazione. Quando inserito in un programma di essi sono effettivamente ignorato dal compilatore, sono esclusivamente destinati ad essere utilizzati come note dagli umani che leggono il codice sorgente. Anche se la documentazione specifica non fa parte del C + + standard, esistono diverse utility che i commenti di analisi con diversi formati di documentazione.
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.
Indice |
[modifica] Sintassi
/* comment */
|
(1) | ||||||||
// comment\n
|
(2) | ||||||||
Spesso conosciuto come "tipo C" o "multi-line" commenti.
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.
Spesso conosciuto come "C + + in stile" o "single-line" commenti.
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.
[modifica] C-stile
C-style commenti sono di solito utilizzati per commentare grandi blocchi di testo, tuttavia, possono essere utilizzati per commentare singole linee. Per inserire un commento in stile C, semplicemente scrivi il testo con
/*
e */
, questo farà sì che il contenuto del commento deve essere ignorato dal compilatore. Anche se non fa parte del C + + standard, /**
e */
sono spesso utilizzati per indicare i blocchi di documentazione, questo è legale perché l'asterisco secondo è semplicemente trattato come parte del commento. Di tipo C i commenti non possono essere annidati.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-stile osservazioni sono spesso preferiti in ambienti in cui C e C + + codice possono essere mescolati, perché sono l'unica forma di commento che può essere utilizzato nello standard C (prima 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.
[modifica] C + + stile
C-style commenti sono di solito usato per commentare singole linee, tuttavia, più C + + di tipo commenti possono essere messi insieme per formare commenti su più righe. C + + in stile commenti dire al compilatore di ignorare tutti i contenuti tra
//
e una nuova linea, che li rende molto utili.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.
[modifica] Esempio
/* 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; }