In C++ the comment
is a line or section of code or text that is not executed as part of the program, and is simply ignored by the compiler.
Comments
are your friend. Use them as often and as much as you like. No special class or library needs to be included to use comments.
The main purpose and benefits for having and using comments are:
C++ supports several ways of commenting:
// This is a single-line comment
/* This is a
multi-line comment */
Single line comments start with two forward slashes (//
).
Any text or code between //
and the end of the line will be ignored by the compiler (will not be executed).
// This is a comment
cout << "Hello World!" ;
cout << "How Are You Today?" ; // This is also a comment
// The following line of code is commented out
//cout << "Let's go already!";
Any text or code between /*
and */
, no matter if it is on a single line, multiple lines, or within code, will be ignored by the compiler (will not be executed):
/* The famous "Hello World!".
This example uses C++ cout command to display it.
Feel free to copy this example and use it however you like.
Modified By : Tim Tolbert
Last Modified: July 16, 2025
*/
cout << "Hello World!" ;
Thank you for reading, I hope you found this blog post (tutorial) educational and helpful.
About | Contact Us | Privacy | Terms & Conditions | © 2025 - T&J Divisions, LLC, All Rights Reserved |