TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

C++ Comments

Overview

C++ comments are explanatory notes that the developer adds to the program source code. These notes will help others to understand the code and the logic.

C++ comments are ignored by the compiler. They are meant for humans to increase the readability of the code. C++ supports two types of comments:

  • Line comment / Single-line comment
  • Multi-line comments

Line comment

Single line comment starts with // and may extend to the end of the line.

// This is an example single line comment

Multi-line comment

C++ multi-line comments start with /* and end with */ and can span multiple lines. This comment is mostly used for blocks of code like program header, function header, etc.

/*

*  This is a sample multi-line

*  C++ comment.

*/

 

C++ Comments

Example

In the example, the first comment is a multi-line comment. We can include information like author name, program description, file name, date, change history, etc. Commercial programs may also include license and copyright information.

 

/************************************
* C++ Comments
* Filename: comments.cpp
* C++ Tutorials - www.TestingDocs.com
* This is an example of multi-line
* comment
*************************************/
#include 
using namespace std;
// Example of single line comment
int main()
{
 int studentNo; // valid identifier
 studentNo = 1001;
 cout << studentNo << endl;
 return 0;
} // end main

—

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

C++ Program to Find Quadratic Equation Roots

C Class Constructor

C++ /

Define C++ Class Constructor

‹ C++ Identifiers› C++ Intrinsic data types

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com