zoukankan      html  css  js  c++  java
  • C++注释和doxygen注释

    C++注释

    C++的注释只有两种:

    1. 单行注释,以“//”开头;
    2. 段落注释,以“/*”开始,以“*/”结束。
    int value; // value是一个整型变量,这是一句单行注释
    
    /*
      Test是一个测试用的类
      这是一段注释中的一行
      这是一段注释中的另一行
    */
    class Test {
    };

    doxygen注释:记住下面3点语法规则就够了

    参照上文C++注释的分类方式,doxygen注释可以这样划分:

    1. 前置单行注释,以“///”开头;
    2. 后置单行注释,以“///<”开头,紧跟代码后面;
    3. 段落注释,以“/**”开始,以“*/”结束。

    doxygen注释不单止是给人看的,在生成文档的时候,程序需要根据约定的语法来识别注释和代码的相对位置,因此doxygen的单行注释可分为前置和后置两种:

    /// value0是一个整型变量,这句注释在代码的前面
    int value0;
    
    int value1; ///< value1是一个整型变量,这句注释在代码的后面

    段落注释也可以分为前置和后置两种,但后置的段落注释意义不大,我反对同学们写后置的段落注释:

    /**
    Test是一个测试用的类
    这是一段注释语句中的一行
    这是一段注释语句中的另一行
    */
    class Test {
    };

    examplesafterdoc.h

    doxygen安装文件夹下的examplesafterdoc.h,内容如下:

    /*! A test class */
    
    class Test
    {
      public:
        /** An enum type. 
         *  The documentation block cannot be put after the enum! 
         */
        enum EnumType
        {
          int EVal1,     /**< enum value 1 */
          int EVal2      /**< enum value 2 */
        };
        void member();   //!< a member function.
        
      protected:
        int value;       /*!< an integer value */
    };

    采用上文的3个语法规则重新调整一下,是不是顿觉豁然开朗了呢?

    /** A test class */
    class Test
    {
    public:
      /**
      An enum type.
      The documentation block cannot be put after the enum!
      */
      enum EnumType
      {
        int EVal1,    ///< enum value 1
        int EVal2     ///< enum value 2
      };
     
      void member();  ///< a member function.
       
    protected:
      int value;      ///< an integer value
    };

    系列文章索引:http://www.cnblogs.com/duxiuxing/p/4301031.html

  • 相关阅读:
    POJ 3126 Prime Path
    POJ 2429 GCD & LCM Inverse
    POJ 2395 Out of Hay
    【Codeforces 105D】 Bag of mice
    【POJ 3071】 Football
    【POJ 2096】 Collecting Bugs
    【CQOI 2009】 余数之和
    【Codeforces 258E】 Devu and Flowers
    【SDOI 2010】 古代猪文
    【BZOJ 2982】 combination
  • 原文地址:https://www.cnblogs.com/duxiuxing/p/4302502.html
Copyright © 2011-2022 走看看