Just want to double check that the default (implicitly defined by compiler) copy constructor for C++ classes performs the copy constructor on each member variable as well using the old value to get the copied value for each member and for atomic objects just uses a bit copy (e.g. ints and floats)
Does the implicitly defined copy constructor in C++ call copy constructor for members too right?
701 views Asked by WilliamKF At
2
There are 2 answers
0
On
Yes. The default copy constructor in C++ will be member-wise copy initialization for every member in the type.
As to how exactly the copy is done for primitive types such as int
and float
I cannot say for certain. My guess is it's implementation specific but most compilers just do a bit by bit copy.
Yes, that is exactly what it does.