c*r
2 楼
They are different in nature. One is contructor, the other
is an operator.
Copy ctor initialize the object, while assignment operator
modifies the existing object.
ClassA X = Y; //need copy ctor for ClassA.
ClassA X;
X = Y; //need assignment operator.
【在 q*c 的大作中提到】
: 我怎么觉得定义了 = 就不需要 copy ctor 了呢?这两个不是重复了吗?
: 那个高手解释解释, 多谢。
is an operator.
Copy ctor initialize the object, while assignment operator
modifies the existing object.
ClassA X = Y; //need copy ctor for ClassA.
ClassA X;
X = Y; //need assignment operator.
【在 q*c 的大作中提到】
: 我怎么觉得定义了 = 就不需要 copy ctor 了呢?这两个不是重复了吗?
: 那个高手解释解释, 多谢。
q*c
3 楼
ft...thanks. make a lot sense.
I only consider class A = B case..
【在 c*r 的大作中提到】
: They are different in nature. One is contructor, the other
: is an operator.
: Copy ctor initialize the object, while assignment operator
: modifies the existing object.
: ClassA X = Y; //need copy ctor for ClassA.
: ClassA X;
: X = Y; //need assignment operator.
I only consider class A = B case..
【在 c*r 的大作中提到】
: They are different in nature. One is contructor, the other
: is an operator.
: Copy ctor initialize the object, while assignment operator
: modifies the existing object.
: ClassA X = Y; //need copy ctor for ClassA.
: ClassA X;
: X = Y; //need assignment operator.
相关阅读
做presentation要简单明了阿老魏阿,要不然你让别人提需求好不好?动态语言和静态语言王垠真在写自己的语言了这个版上,Netflix工作的不止goodbug一个吧?我所知道的goodbug其人 (转载)groovy连hello world都是法语老魏,你能不能不PA?老魏,我今天一次都没有PA你,你干吗骂我?这么多讨论的,你们用过12306吗?看看大牛们为什么都远离.net每秒500万, 结论出来看了关于java的入门请教准备在我的网站上发片文章我看到的12306c++ thread 求助有人用bash吗?老魏来说说,超级路由怎么样?Guido on Python AsyncIO (1/23/2014)我来写个老魏的详细实现方案。(更新了缺点)