编译器实现的默认函数 [英] Default functions implemented by compiler
问题描述
这个问题似乎很愚蠢。当我们对一个类进行decalre时,可以找出编译器实现的默认
函数
A类
{
}
根据我的说法,此声明将定义默认函数,例如
1.默认构造函数
2.默认Destrucor
3.复制构造函数
我还缺少其他任何功能吗?
This question seems to be silly. Can ony one figure out the default
functions implemented by compiler when we decalre a class like
class A
{
}
According to me this declaration will define default functions like
1. Default Constructor
2. Default Destrucor
3. Copy Constructor
Is there any other functions i am missing?
推荐答案
su****@gmail.com 写道:
这个问题似乎很愚蠢。当我们对类似的类进行decalre
时,可以找出编译器实现的默认函数。
}
A级
{
};
根据我的说法,这个声明将定义默认功能,如
1.默认构造函数
2.默认Destrucor
3.复制构造函数
我还缺少其他任何功能吗?
This question seems to be silly. Can ony one figure out the default
functions implemented by compiler when we decalre a class like
class A
{
}
class A
{
};
According to me this declaration will define default functions like
1. Default Constructor
2. Default Destrucor
3. Copy Constructor
Is there any other functions i am missing?
否
No
" Salt_Peter" < PJ ***** @ yahoo.com>写道:
"Salt_Peter" <pj*****@yahoo.com> writes:
su****@gmail.com 写道:
这个问题似乎很愚蠢。当我们对像
This question seems to be silly. Can ony one figure out the default
functions implemented by compiler when we decalre a class like
这样的类进行decalre时,可以找出编译器实现的默认函数。
{
};
class A
{
};
根据我的说法,这个声明将定义默认函数,如
1.默认构造函数
2.默认Destrucor
3.复制构造函数
我还缺少其他功能吗?
According to me this declaration will define default functions like
1. Default Constructor
2. Default Destrucor
3. Copy Constructor
Is there any other functions i am missing?
否
No
我不同意!
Scott Meyers在Effective C ++第5章中写道,
也可以生成复制赋值运算符。
请注意,列出的函数仅在生成时生成需要。
祝愿
I disagree!
Scott Meyers writes in Effective C++ chapter 5 that
also the copy assignment operator may be generated.
Note that the listed functions are generated only when needed.
Best wishes
" Marco Wahl" <毫安******** @ gmail.com> schrieb im Newsbeitrag
新闻:11 ********************** @ x69g2000cwx.googlegr oups.com ...
"Marco Wahl" <ma********@gmail.com> schrieb im Newsbeitrag
news:11**********************@x69g2000cwx.googlegr oups.com...
Salt_Peter < PJ ***** @ yahoo.com>写道:
"Salt_Peter" <pj*****@yahoo.com> writes:
su****@gmail.com 写道:
这个问题似乎很愚蠢。当我们对像
This question seems to be silly. Can ony one figure out the default
functions implemented by compiler when we decalre a class like
这样的类进行decalre时,可以找出编译器实现的默认函数。
{
};
class A
{
};
根据我的说法,这个声明将定义默认函数,如
1.默认构造函数
2.默认Destrucor
3.复制构造函数
我还缺少其他功能吗?
According to me this declaration will define default functions like
1. Default Constructor
2. Default Destrucor
3. Copy Constructor
Is there any other functions i am missing?
没有
No
我不同意!
Scott Meyers在Effective写道C ++第5章也可以生成复制赋值运算符。
请注意,列出的函数仅在需要时生成。
I disagree!
Scott Meyers writes in Effective C++ chapter 5 that
also the copy assignment operator may be generated.
Note that the listed functions are generated only when needed.
还应该提到的是,没有默认析构函数。
只是默认实现。 默认构造函数是任何
构造函数,可以在没有任何参数的情况下调用它。它叫做
" default"因为在创建对象时没有明确指定其他构造函数时使用它,而不是因为编译器提供的实现是
。
>
Heinz
It should also be mentioned that there is no "default destructor". There
only is a default implementation. A "default constructor" is any
constructor, which can be called without any arguments. It is called
"default" because it is used when no other constructor is explicitly
specified when an object is created, not because its implementation is
provided by the compiler.
Heinz
这篇关于编译器实现的默认函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!