C++ Tutorials

C++ Tutorials

Comments are an important part of any programming language. They help the person writing a program, and anyone else who must read the source file and understand what’s going on. The compiler ignores all comments. Comments do not add to the file size or execution time of the executable program.

C++ supports single-line and multi-line comments.

single-line comment example :

The // (two slashes) characters, followed by any sequence of characters. A new line not immediately preceded by a backslash terminates this form of comment. Therefore, it is commonly called a “single-line comment.”

    // this is single line comment.

multi-line comment example :

The /* (slash, asterisk) characters, followed by any sequence of characters (including new lines), followed by the */ characters. This syntax is the same as ANSI C.

    /* C++ comments can also
    span multiple lines