Basically, what CPUWizard and Graham are stating is that the copy constructor is called whenever the compiler feels neccessary, (necessary meaning the compiler cannot or does not have the ability to optimize the copy construction away).

Regardless, the coder must always write their user-defined copy constructor if the language requires it (i.e. the class has reference members, and a copy is invoked, even if the compiler can optimize the copy away).

Moreover, many times on interviews, the interview question is "how many times is the copy constructor called in this example?". This is a trick question, since the answer is "it depends on the compiler", and never a concrete number of times. If the answer the interviewer gives is "it is called twice" or "it's called three times", or some set number of times, the interviewer should be the one looking for a job, as that answer is incorrect.

Regards,

Paul McKenzie