Reputation: 43139
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)
Upvotes: 1
Views: 708
Reputation: 754763
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.
Upvotes: 3