拷贝和移动赋值运算符不应为虚函数
6.8.11 ID_virtualAssignment
拷贝和移动赋值运算符的参数应分别为所属类的左值和右值引用,这类运算符即使是虚函数也不便于被重写。
示例:
class A {
public:
virtual A& operator = (const A&); // Non-compliant
};
class B: public A {
public:
virtual B& operator = (const B&); // Not override
virtual A& operator = (const A&); // Override, but too complex
};
相关
依据
ISO/IEC 14882:2003 12.8(9)
ISO/IEC 14882:2011 12.8(17)
ISO/IEC 14882:2011 12.8(19)