由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - compiler created methods
相关主题
急问:compile and build dependency问一个empty class的size的问题
c++ dynamic castfind bugs of c++ codes
a c++ question没有经过构造函数???
求教:c++中如何从raw data中创建对象?问个 ctor/copy ctor的问题
one question about operator deletepointer to base class = new derived, what will happend??
一道c++的考古题c++ singleton questions
请问关于c++实现singleton的问题?请教一个c++ throw exception 问题
C++ 书推荐我这个C++程序有没有什么问题啊?请指点。。。谢谢。。。
相关话题的讨论汇总
话题: compiler话题: ctor话题: created话题: methods话题: true
进入Programming版参与讨论
1 (共1页)
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?

1 (共1页)
进入Programming版参与讨论
相关主题
我这个C++程序有没有什么问题啊?请指点。。。谢谢。。。one question about operator delete
C++的一个小疑问,求解惑一道c++的考古题
一个C++面试题分析请问关于c++实现singleton的问题?
C++设计疑问C++ 书推荐
急问:compile and build dependency问一个empty class的size的问题
c++ dynamic castfind bugs of c++ codes
a c++ question没有经过构造函数???
求教:c++中如何从raw data中创建对象?问个 ctor/copy ctor的问题
相关话题的讨论汇总
话题: compiler话题: ctor话题: created话题: methods话题: true