[CSI] pass by value parameter in a copy constructor
Mikhail Nesterenko
mikhail at cs.kent.edu
Tue Nov 12 16:00:49 EST 2019
CSI students,
A copy constructor takes its parameter by reference. It does not take
a parameter by value. The reason is that a copy constructor defines
the semantics of copying and copying is what needs to happen when a
parameter is passed by value.
I was asked what happens if a programmer tries to define a copy
constructor. It turns out, nothing good. This is explicitly prohibited
by C++ standard.
Here is a link with more details.
https://stackoverflow.com/questions/2685854/why-should-the-copy-constructor-accept-its-parameter-by-reference-in-c
Thanks,
--
Mikhail
More information about the cs13001
mailing list