There's a code. If you do CTest t; in the main function, call the constructor and t.m_Value = 0; Put 1 in t.m_Value and t.The m_value is 1 It is understandable that t1 takes the member data value as it is through the copy generator below.
I think the reason why there is a difference between t2 and t3 is whether or not an object is initialized when it is created It looks like a difference, but it's a little confusing. t2 is the substitution as the object is created, so it goes into the copy generator Since t3 is substituted after the object is created, is it just treated as a copy-to-put operator?c++
The three above are the same thing.
If you want
CTest1=t; to stop working, you can explicitly put the
exploit keyword in front of the constructor as shown below.
explicit and then compile it. Then
CTest1=t; will cause an error.
© 2022 pinfo. All rights reserved.