我应该在哪里提交文件评论? [英] Where should I put documentation comments?

查看:176
本文介绍了我应该在哪里提交文件评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  / 

在包含转发声明的头文件中,或包含实现的.cpp文件, /header.h
/ *关于foo()* /
void foo();
/ *关于bar()* /
int bar();
/ *关于A * /
类A
{
public:
/ *关于A的构造函数* /
A();
....
}

  // implementation.cpp 
/ *关于foo()* /
void foo()
{
...
...
}
/ *关于酒吧* /
int bar()
{
...
}
/ *关于A的构造函数* /
A :: A()
{
...
}


解决方案

对于使用信息,放入标题更好。这是人们首先看的地方。



如果没有人必须检查您的.cpp文件来确定应该如何使用组件,那么文档是非常成功的。 >

In the header file containing the forward declarations, or in the .cpp file containing the implementations, like this?

//header.h
/* About foo() */
void foo();
/* About bar() */
int bar();
/* About A */
class A
{
public:
    /* About A's constructor */
    A();
    ....
}

Or

//implementation.cpp
/* About foo() */
void foo()
{
    ...
    ...
}
/* About bar */
int bar()
{
    ...
}
/* About A's constructor */
A::A()
{
    ...
}

解决方案

For usage information, it's nicer to put into the header. That's where people would look first.

The documentation is really successful if no one has to examine your .cpp file to figure out how the component should be used.

这篇关于我应该在哪里提交文件评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆