What happens (for sure) if you leave the constructor instance in the C ++ class?

What happens (for sure) if you leave a constructor copy in a C ++ class?

Is the class just memcpy'd or is the member copied wise?

+5
source share
4 answers

The class is copied by member.

This means that copy constructors of all members are called.

+8
source

The default copy constructor is made by mebmber wise.

The same element-based approach is also used to create an assignment operator; the assignment operator, however, is not created if the class has reference elements (because it is impossible to restore the link after construction).

+1

, . : , , .

0

, , - , - , () , . , , .

However, if you are implementing a copy constructor, do not forget the Rule of Three : copy constructor, assignment operator, and destructor. If it is implemented, all three must be implemented.

Regards,
Dennis M.

0
source

All Articles