这个问题你前面已经说过了,返回自己的时候是不会生成临时对象的
恩,我了解了...其他情况的话只要函数返回对象就一定会用COPY CONSTRUCTOR生成临时对象的
是吧?
是这样的,我做了很多测试
如果你功力可以,你干脆看看<<inside the c++ object model>>
c++/C + 汇编 = 天下无敌
是这样的,我做了很多测试
如果你功力可以,你干脆看看<<inside the c++ object model>>
这个绝对是会调用copy constroctor
因为 Sample s1=Sample s2(.....)相当于 Sample s1(s2)
[此贴子已经被作者于2006-7-24 23:48:10编辑过]
这个绝对是会调用copy constroctor
因为 Sample s1=Sample s2(.....)相当于 Sample s1(s2)
My apologize,I misnunderstood you a little bit
I mean:
Sample s1=Sample (...);
Then,what about this time?
My apologize,I misnunderstood you a little bit
I mean:
Sample s1=Sample (...);
Then,what about this time?
#include<iostream>
using namespace std;
class text
{
public:
text(){ cout << "hello constroctor" <<endl;}
text(const text &t){ cout << "hello copy" << endl;}
};
int main()
{
text t1 = text(text());
text t2 = text();
}
我的编译器是vc.net做了优化,所以调用 text()但是按照语法,是调用text(text &),
No intention to have a test for oyur guys here,
you two have been elcted to be the "Ban Zhu"here,
but i'm just a freshman for C plus plus...
you flattered me a lot!
Thanks...