tags:

views:

139

answers:

3

Could anyone please suggest a proper format of comments I should use in a C++ project? I think that there is some analog of javadoc format, but I can't find which one. Is there any de-facto standard of that kind? Thanks!

+15  A: 

Doxygen is used rather frequently for C++ projects (Doxygen supports other languages as well). You can use Doxygen-style comments as a starting point (here are some examples). Just be consistent.

In silico
+1, I consider doxygen to be a *de facto* standard for documentation comments.
David Rodríguez - dribeas
+1: totally agree.
Dacav
+2  A: 

Your mention of javadoc suggests you might be thinking of doxygen. This is a kit which supports structured comments in C++ and other languages, and can produce output in HTML and (if I recall correctly) PDF. It supports a variety of comment styles, including one which looks very much like javadoc.

It works well, and is broadly used.

Norman Gray
+1  A: 

It's quite controversial as a subject in every language.

While I appreciate the Doxygen answers, since it's effectively kind of a de facto standard, Doxygen itself supports multiple formats.

C++ supports 2 styles of comments:

  • /**/ multi-line comment
  • // until the end of line comment

I would advise not to use the former style. The issue is that it does not nest, which is quite annoying when for testing purpose you wish to comment out a whole block of code.

My 2 cents, as the saying goes.

Matthieu M.
Although disabling code for testing is often better done with `#if 0` / `#endif`.
Josh Kelley