How do I format c++ comments properly?
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!
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.
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.
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.
精彩评论