c++中的默认参数
Default parameter in C++
使用默认参数时,我设置
void method1(float v, float w =1.0)
在定义中使用像
这样的注释是个好习惯吗?void class::method1(float v, float w /*=1/0*/)
我更喜欢这样的氧兼容文档:
/**
* 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);
通常我不会在实现特定块中添加额外的注释,
智能在大多数IDE将工作,如果不是你可以保留评论。我不认为这有什么害处。
相关文章:
- 使函数参数默认为周围范围
- 如何将值传递给其参数(默认参数)
- 当“std::make_index_sequence”和“std::index_sequence”用于模板参数默认类型时
- C ,构造器中允许的参考参数默认值
- 哪些规则控制参数默认赋值?
- 错误:上一个规范后给出的参数默认参数
- 是否可以设计一个包含模板参数默认值的类
- 构造函数中参数C++默认值
- 如何设置依赖于其他参数的参数默认值
- C++模板参数默认函数实现
- QInput对话框参数默认值
- g++4.8.2上列表方法参数默认初始化时出错
- 在函数定义中指定参数默认值会导致错误 C2143:语法错误:'='之前缺少')'
- 函数模板:将第一个模板参数默认为第二个
- 模板模板参数默认可以引用其他模板类型的参数
- 参数默认为先例参数的值
- 如何修改一个类,使它只有一个成员函数,所有参数默认
- 内置类型的模板参数默认值
- 是否可以使用构造函数或对象作为其他类方法的参数默认值?
- 模板参数默认为更高版本