Go4Expert Tutorials

Programming And Web Development Tutorials

 
  • Home
  • Tutorials
  • Python
  • PERL
  • ASP.Net
  • C++
You are here: Home / Tutorials / C++ / Comments in C++

Comments in C++

Comments are the simple text written by the coder to make understanding clear for the people who read it later or for self-understanding at a later stage. Comments are a very essential part of coding and are considered as one of the good practices while coding.

All programming language allows some form of commenting. CPP supports both single and multiple line commenting, all text inside these comments are completely ignored by the compiler.

For Single Line Comment use two slashes ( //  )

//This is a single line comment
Single line comment ends at end of that line I.e. until Enter is pressed to commence a new line.

For multiple lines commenting use slash with the asterisk ( /*......*/ )

/* This is a
multiple
line
comment */

Multiple line comments start and end at slash with the asterisk, using this you can comment various lines of your code at an instant

Benefits of Proper Commenting:

  1. It makes your Code more readable.
  2. It adds meaning to your code for others.
  3. It helps in even debugging your code.
« CPP Basic Syntax and Terms Datatypes in CPP »

Table of Content

  • CPP Overview
  • Local Environment Setup
  • CPP Basic Syntax and Terms
  • Comments in C++
  • Datatypes in CPP
  • Defining Variables in CPP

© Go4Expert Tutorials 2004 - 2025. All Rights Reserved.