为什么一个拷贝构造函数有多个参数? [英] Why would a copy constructor have more than one parameter?
问题描述
$ 12.8 / 2 - '类X的非模板构造函数
是一个复制构造函数,如果
它的第一个参数是类型X&
const X& amp; volatile X&或const
volatile X&,并且没有
其他参数或者所有其他
参数具有默认参数
(8.3.6).106)'
$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)'
到目前为止,我没有遇到任何需要声明一个带有默认参数的复制构造函数的情况。
So far, I have not come across any example of a situation where there is a need to declare a copy constructor with additional default parameters.
想知道任何实时使用这样的复制构造函数,它需要多个参数。
Would like to know any real time use of such a copy constructor which take more than one parameter.
推荐答案
旧的 std :: basic_string
也有一个:
basic_string(const basic_string& s,
size_type pos = 0, size_type n = npos)
这篇关于为什么一个拷贝构造函数有多个参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!