C++定义 3 个参数,但只使用 2 个
C++ define 3 arguments but using just 2
我想使用不同数量的参数。
class A {
public:
A(int a, int b);
};
A::A(int a, int b) {
// constructor code
}
int main() {
A a(5); // I use only 1 argument and the second one I let default ?
}
构造函数是(有点特殊的)函数 - 常规默认参数语法适用。
class A {
public:
A(int a, int b = default_value);
};
A::A(int a, int b) {
// constructor code
}
int main() {
A a(5);
}
相关文章:
- 部分定义/别名模板模板参数
- 有没有办法使用 googletest 创建自定义参数生成器?
- 使用自定义参数的过载删除操作员
- C++ 默认参数的重新定义:参数 1 (矢量 2D)
- Cython:具有自定义参数类型的STD ::功能回调
- 让我们C++推断定义参数的类/命名空间的位置
- 将自定义参数传递到Qt/C++中的插槽
- 定义参数包扩展的"pattern",尤其是在函数调用中
- 使用自定义参数进行 QAction
- 具有未定义参数的私有副本构造函数
- Qt-具有自定义参数的可重用绘制函数
- 类型定义参数的重载
- 如何调用定义参数为空的函数
- 如何正确使用作为其他定义参数的定义?C++
- 框架的用户定义参数应该在哪里
- 带有自定义参数的Sendmessage /postmessage
- c++定义参数重载
- Boost c++ Phoenix用户定义参数的下标操作符[]错误
- 是否可以在预处理器中定义参数化列表?
- c++中可变的用户定义参数列表