Thursday, June 19, 2014

Comments

Comments do not affect the operation of the program; however, they provide an important tool to document directly within the source code what the program does and how it operates.
and they're ignored from compiler but makes source code to read easier from you and others and to know that program will do.

in C++ are two ways to make comments
First
// Line Coment
// Line 2 Comment
// Line 3 Comment

Second
/*Block Comments
Line 2

Line 3*/
Lets add some comments into our program

/* myprogram in C++
   with more comments */
#include <iostream>
int main ()
{
  std::cout << "Hello World! ";     // prints Hello World!
  std::cout << "I'm a C++ program"; // prints I'm a C++ program
} 
If comments are included within the source code of a program without using the comment characters combinations //, /* or */,
 the compiler takes them as if they were C++ expressions, most likely 
causing the compilation to fail with one, or several, error messages. 

No comments:

Post a Comment