C++ Comments

Introduction

Single line comments in C++ start with double slashes // and the compiler ignores them.

We use them to comment or document the code or use them as notes:

int main() 
{ 
    // this is a comment 
} 

We can have multiple single-line comments:

int main() 
{ 
    // this is a comment 
    // this is another comment 
} 

Multi-line comments start with the /* and end with the */.

They are also known as C-style comments.

Example:

int main() 
{ 
    /* This is a 
    multi-line comment */ 
} 



PreviousNext

Related