assign
and operator=
1、是在思考virtual operator=
时,在 CppCoreGuidelines C.60: Make copy assignment non-virtual
, take the parameter by const&
, and return by non-const&
中,有这样的描述:
Alternatives: If you think you need a
virtual
assignment operator, and understand why that's deeply problematic, don't call itoperator=
. Make it a named function likevirtual void assign(const Foo&)
. See copy constructor vs.clone()
这引发了我对assign
and operator=
的思考