1. Home
  2. Computing & Technology
  3. C / C++ / C#

Definition of Comment

By David Bolton, About.com

Definition: Source Code should be written to be self-commenting. This means using reasonable length variable names, consistent indentation and perhaps some kind of type indication in the name. Here are some examples :
int * pint;
int * ptrint;
int ivalue;
float fnumber;

Comments

C, C++ and C# all provide the same type of comments. They are
  • Single line starting with // (C++ and C#) Note 1
  • All text between /* and */ (C, C++ and C#)
  • Special comments with /// < comment tag>Note 2
Note 1 - Single line comments in C are not regarded as very portable. Some compilers e.g. Microsoft's Visual C++ will accept them. Other's won't.

Note 2 - Microsoft's Visual C# has a compiler option /doc that will extract all comment XML tags from the file and put them in a file.

Commenting Systems

There are a number of documentation systems that can extract Documentation from your source code. An example is the Open Source Doxygen.

Glossary:

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Explore C / C++ / C#
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. C / C++ / C#

©2009 About.com, a part of The New York Times Company.

All rights reserved.