Item 12. Assignment and Initialization Are Different

xiaoxiao2021-03-05  28

Item 12. Assignment and Initialization Are Different

Yes, assignment is different from initialization, which is attributed to the different function assignment: operator = operator initialization: copy constructor

-------------------------------------------------- ------------- 1, when is the assignment? Of course, there is "=" place, the rest is to call the copy constructor, such as when the function is incorporated into the parameter.

2, when is the custom class need to rewrite? Effective C said that when there is a pointer data member, and the data member is New from the class, the memory disclosure occurs when copying.

3. When the problem of rewriting the attention is overwritten Operator =, the original memory will be released first.

Detailed reference e11

转载请注明原文地址:https://www.9cbs.com/read-37208.html

New Post(0)