OneBite.Dev - Coding blog in a bite size

create comments in C++

Code snippet on how to create comments in C++

  // This is a comment in C++
  /* This is another comment in C++ */

The first line of code is a single line comment in C++. This type of comment is indicated with a double forward slash (//). Anything after the // is a comment, and will be ignored by the compiler.

The second line of code is a multi-line comment. It’s indicated with the slash and asterisk (/) and the comment ends when it reaches the slash and asterisk followed by a single forward slash (/). Anything between the /* and */ will be ignored by the compiler.

Comments are used by programmers to provide context, information, and instructions to other programmers who wish to understand the code, or to fellow collaborators working on the same project. They can be used to explain the purpose of a particular code block and can improve the readability and clarity of code.

c-plus-plus