Cpp-Primer
Cpp-Primer copied to clipboard
Answer to Exercise 13.16 might be wrong
In the answer to exercise 13.16 it is stated that "the three Output are the same", but I think this is wrong, because although copy constructor is not called when f() is called, the copy constructor is called when we initialize b from a, and also c from b. So, a, b, and c have different serial numbers. The code provided in exercise 13.17 for exercise 13.16 also prints three different numbers (10, 11, and 12).
I agree with you.
- ex13.15: copy constructor will be called five times.
- ex13.16: copy constructor will be called twice.
That's the difference.
I think so, I want to ask this question too.
I also agree with you:)
I agree with you. I have test it in VS2019 and the result is (10, 11 and 12).
Right! I also test in VS and it does output different answers!