Closed. This question is opinion-based 。它目前不接受答案。












想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文来回答。

3年前关闭。



Improve this question




我想通过注释行在我的代码中添加文档。
是否有任何标准格式?

例如,考虑下面的代码:
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);
}

对于这个示例代码,有没有更好的方法来编写注释行?

最佳答案

对于 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);

10-07 23:23