简体   繁体   English

C ++中的默认参数

[英]Default parameter in C++

when using default parameter, I set 当使用默认参数时,我设置

void method1(float v, float w =1.0)

Is this a good practice to use the comment in the definition like 在定义中使用注释是否是一种好习惯?

void class::method1(float v, float w /*=1/0*/)

I would prefer some doxygen compliant documentation this way: 我希望以这种方式获得一些符合doxygen的文档:

/**
 * Description of the behavior/purpose of your method
 * 
 * @param v The float 'v' (whatever this means)
 * @param w Optional float 'w' (whatever this means), default value is 1.0.
 */
void method1(float v, float w =1.0);

Usually I'm not going to put additional comments with implementation specific blocks, 通常,我不会在实现特定的块中添加其他注释,

Intellisence in most of the IDE will work, if not you can keep comment as well. 大多数IDE中的智能功能都可以使用,否则,您也可以保留注释。 I do not think any harm in this. 我认为这不会造成任何伤害。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM