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.
相关阅读
java真是让人纠结what's the svn cmd likes "cleartool lsvtree" ?请教一个优化问题学习Java有什么宝典?redis 存储 object的问题: 每个object一个hash, 这样能行吗?Time series big data大家觉得怎么存储比较好?Visual Studio 2013新文件模板Java的经典参考书怎么都很陈旧深度学习 model compression把web service+client 包装成一个桌面GUI 软件容易吗?李彦宏:百度牵头组建深度学习国家队 向女排学习zt (转载)python pickle 目的是什么feifei 又有新闻Android论坛框架问个比较低级的问题吧码工,AI之外的事儿你怎么看?block chain和iotCNN做NLP工程多吗?机器,或者是所谓人工智能,不太可能完全取代人。请教good hash function