在C++中,我不清楚从复制赋值运算符返回引用的概念.为什么复制赋值运算符不能返回新对象的副本?另外,如果我上课A,还有以下内容:
A a1(param);
A a2 = a1;
A a3;
a3 = a2; //<--- this is the problematic line
Run Code Online (Sandbox Code Playgroud)
的operator=定义如下:
A A::operator=(const A& a)
{
if (this == &a)
{
return *this;
}
param = a.param;
return *this;
}
Run Code Online (Sandbox Code Playgroud) c++ operator-overloading copy-constructor assignment-operator