[C++进阶]在operator=中处理"自我赋值"
作者:
小鱼号的代码日记 | 来源:发表于
2020-09-06 23:14 被阅读0次/***************************
effectivre c++
改善编程与设计的55个具体做法
条款11:在operator=中处理"自我赋值"
---------小鱼号的代码日记--------------
****************************/
class widget
{
public:
widget& operator =(const widget& rhs)
{
if(this == &rhs)
return *this;
///....
///
return *this;
}
widget& operator +=(const widget& rhs)
{
return *this;
}
};
#include <QCoreApplication>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
/*****
内容选自:
effectivre c++
改善程序与设计的55个具体做法
*****/
本文标题:[C++进阶]在operator=中处理"自我赋值"
本文链接:https://www.haomeiwen.com/subject/nrihektx.html
网友评论