c++ - 为什么复制构造函数会有多个参数?

标签 c++ copy-constructor

$12.8/2 - 'A non-template constructor for class X is a copy constructor if its first parameter is of type X&, const X&, volatile X& or const volatile X&, and either there are no other parameters or else all other parameters have default arguments (8.3.6).106)'

到目前为止,我还没有遇到任何需要声明带有附加默认参数的复制构造函数的示例。

想知道这种带有多个参数的复制构造函数的实时使用情况。

最佳答案

旧的 std::basic_string 也有一个:

basic_string(const basic_string& s, 
         size_type pos = 0, size_type n = npos)

关于c++ - 为什么复制构造函数会有多个参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3648797/

相关文章:

c++ - 如何将文本文件加载到QListwidget并将其保存回去

c++ - 删除 std::map 中的特定元素

c++ - 赋值运算符重载有类似的转换(仅在 VS 中)

c++ - 从复制构造函数调用默认赋值运算符是不好的形式吗?

c++ - 在链表中移动和复制构造函数

c++ - 如何复制(或交换)包含引用或常量成员的类型的对象?

c++ - 确定客户端 Internet 连接(InternetGetConnectedState() 谎言)

c++ - 自动类型默认为 int 而不是 long

c++ - 为什么 move 比通过 const& 传递更昂贵?

c++ - 从文本文件读取问题?