可以肯定的是copy constructor没有返回参数,而且我测试过,编译器合成的默认构造也不会以值来传递.
虽然做这种测试已经是很傻了.
看了10几分钟.作者说得是这句
// Pass and return BY VALUE:
HowMany f(HowMany x) {
x.print("x argument inside f()");
return x;
}
"Because the copy-constructor implements pass and return by value,
it’s important that the compiler creates one for you in the case of
simple structures – effectively, the same thing it does in C."
作者意思就是,复制构造会在以值的方式进行传参和以值返回的情况下发生.所以就编译器来说,对普通的struct创建默认的复制构造函数,这很重要.实际上,在C语言中编译器就是这么做的.
原话是应该少了个when
Because the copy-constructor implements (when) pass and return by value