c++基本语法模板
以 /*! 开头, */ 结尾
/*!\关键字1\关键字2
*/
1 文件头部信息
/*! \file ClassA.h* \brief 文件说明 定义了类fatherA* \details This class is used to demonstrate a number of section commands.* \author John Doe* \author Jan Doe* \version 4.1a* \date 2023-2199* \pre First initialize the system.* \bug Not all memory is freed when deleting an object of this class.* \warning Improper use can crash your application* \copyright GNU Public License.*/
2 class
/*! \class Test classA.h "inc/classA.h"\brief fatherA类Some details about the Test class.*/
2 变量
/*! \var int errno\brief Contains the last error code.\warning Not thread safe!
*/
3 函数
例子1
/*! \fn int read(int fd,char *buf,size_t count)\brief Read bytes from a file descriptor.\param fd The descriptor to read from.\param buf The buffer to read into.\param count The number of bytes to read.
*/
例子2
/*! \fn void Overload_Test::drawRect(int x,int y,int w,int h)* This command draws a rectangle with a left upper corner at ( \a x , \a y ),* width \a w and height \a h. */
例子3
class Fn_Test
{public:const char *member(char,int) throw(std::out_of_range);
};const char *Fn_Test::member(char c,int n) throw(std::out_of_range) {}/*! \class Fn_Test* \brief Fn_Test class.** Details about Fn_Test.*//*! \fn const char *Fn_Test::member(char c,int n) * \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.*/
4 重载
/*!* \overload void Overload_Test::drawRect(const Rect &r)*/
5 结构体
/*! \struct CoordStruct* A coordinate pair.*/
struct CoordStruct
{/*! The x coordinate */float x;/*! The y coordinate */float y;
};
6 枚举
class Enum_Test
{public:enum TEnum { Val1, Val2 };/*! Another enum, with inline docs */enum AnotherEnum { V1, /*!< value 1 */V2 /*!< value 2 */};
};/*! \class Enum_Test* The class description.*//*! \enum Enum_Test::TEnum* A description of the enum type.*//*! \var Enum_Test::TEnum Enum_Test::Val1* The description of the first enum value.*/
7 宏
/*! \brief Computes the absolute value of its argument \a x.\param x input value.\returns absolute value of \a x.
*/
#define ABS(x) (((x)>0)?(x):-(x))/*!\def MAX(x,y)Computes the maximum of \a x and \a y.
*/
#define MAX(x,y) ((x)>(y)?(x):(y))
还有其他关键字,就不一一列举了:
手册里面有详细说明,并有例子