g*********s 发帖数: 1782 | 1 is the following true?
copy ctor, assignment, and dtor are always created by the compiler if they
are not declared by the user.
default ctor, however, is created by compiler only when there's not any
user defined
ctor.
just feel the last one is weird. why compiler cannot create a default ctor
when a copy ctor defined? | p*****w 发帖数: 429 | 2
no true
true
maybe you want to have this feature.
【在 g*********s 的大作中提到】 : is the following true? : copy ctor, assignment, and dtor are always created by the compiler if they : are not declared by the user. : default ctor, however, is created by compiler only when there's not any : user defined : ctor. : just feel the last one is weird. why compiler cannot create a default ctor : when a copy ctor defined?
| a****l 发帖数: 8211 | 3 I don't think it is necessarily true. The reason is simple: compiler
optimization.So, if a function is needed, it will appear in the final code;
if not, it will be removed by any self-respecting compiler.
Even a dtor might not be needed. E.g, the class only has static members...
【在 g*********s 的大作中提到】 : is the following true? : copy ctor, assignment, and dtor are always created by the compiler if they : are not declared by the user. : default ctor, however, is created by compiler only when there's not any : user defined : ctor. : just feel the last one is weird. why compiler cannot create a default ctor : when a copy ctor defined?
|
|