Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) comment

 

A comment is text in code that is written for only humans to read as a form of documentation.

 

int main()
{
  //Single-line comment

  /*

  Multi-line comment

  */
}

 

It is adviced to comment your code well [1] as it is an important form of documentation. For example, prefer to document the interfaces so that they are able by others [2]. Keep the comments crisp [3]. Don't say in comments what can be clearly stated in code [4]. State intent in comments [5].

 

 

 

 

 

References

 

  1. Bjarne Stroustrup. Programming. 2009. ISBN: 978-0-321-54372-1. Chapter 5.9.1: 'Comment your code well'
  2. John Lakos. Large-Scale C++ Software Design. 1996. ISBN: 0-201-63362-0. Chapter 2.6: Document the interfaces so that they are usable by others. Have at least one other developer review each interface
  3. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice. page 240: '[8] Keep comments crisp'
  4. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice. page 240: '[9] Don't say in comments what can be clearly stated in code'
  5. Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 9.8. Advice. page 240: '[10] State intent in comments'

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict