JavaScript Error

You currently have JavaScript disabled on your web browser.

This website uses JavaScript, and This web page needs JavaScript activated to work correctly.

Please active JavaScript on your web browser and then refresh this web page.



Comments



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:

Examples

C++ supports several ways of commenting:

 
// This is a single-line comment

/* This is a
multi-line comment */

Single-Line Comments

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!";

Multi-Line Comments

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!";


Final Thoughts

Thank you for reading, I hope you found this blog post (tutorial) educational and helpful.


(0) pollYesResult
(0) pollNoResult



 
     About   |   Contact Us   |   Privacy   |   Terms & Conditions   |   © 2025 - T&J Divisions, LLC, All Rights Reserved