注释格式规范:
1.每个.h文件的头部,必须添加注释,格式如下:
/** \file file.h
* A brief file description.
* A more elaborated file description.
*/
或者用这种方式
/////////////////////////////////////////////////////////////////////////////
// Name: filename.h
// Purpose: xxxxxx
// Author: stone xin
// Modified by: xxxxx
//
// Created: 22/06/2009
// Copyright: (c) xxxxx
// Licence: GNU licence
/////////////////////////////////////////////////////////////////////////////
2.每个类的声明上方,添加注释,格式如下:
/** \class Test
* \brief This is a test class.
*
* Some details about the Test class
*/
class Test
{
...
};
3.每个成员变量及成员函数的定义的右边或上方,添加注释,格式如下:
/** Some details about the function open */
void open();
4.每个全局函数、全局变量、宏定义的定义的右边或上方,添加注释,格式如下:
/** Some details about the function GlobalFunc*/
void GlobalFunc();
5.每个.cpp文件头部,添加注释,格式同头文件
6.每个函数的实现上方,添加注释,格式如下:
/** \brief A member function.
* \param c a character.
* \param n an integer.
* \exception std::out_of_range parameter is out of range.
* \return a character pointer.
*/
const char *member(char,int) throw(std::out_of_range)
{
}
7.每个枚举定义添加注释,格式如下:
/** Another enum, with inline docs */
enum AnotherEnum
{
V1, //< value 1
V2 //< value 2
};
8.实现代码中关键的代码加注释,格式如下:
{
//some details about the next line code
if (Button1->Enabled)
{
}
}