如何以正确的方式编写代码内注释和文档?这有什么标准吗?

hkB*_*sai 4 c++ documentation standards comments

我想通过注释行在我的代码中添加文档.
这有什么标准格式吗?

例如,请考虑以下代码:

class Arithmetic
{
    // This method adds two numbers, and returns the result.
    // dbNum1 is the first number to add, and dbNum2 is second.
    // The returning value is dbNum1+dbNum2.
    static double AddTwoNumbers(double dbNum1, double dbNum2);
}
Run Code Online (Sandbox Code Playgroud)

对于此示例代码,是否有更好的方法来编写注释行?

Mic*_*Mic 5

对于c ++,没有像javadoc那样的标准,但是某些文档工具很流行且常用.在我的头顶,我可以提到doxygen.

Doxygen还支持熟悉的javadoc样式,即:

/**
   This method adds two numbers, and returns the result.
   @param dbNum1 is the first number to add
   @param dbNum2 is second.
   @return The returning value is dbNum1+dbNum2.
*/
static double AddTwoNumbers(double dbNum1, double dbNum2);
Run Code Online (Sandbox Code Playgroud)


And*_*hko 5

您可以格式化您的注释,以便以后生成文档.最受欢迎的工具是DoxyGen