【操作符重载】等号的两种形式
1.
void operator= (const SomeClass& C) {
....
}
2.
SomeClass& operator= (const SomeClass& C) {
....
return *this;
}
结论:Both are legal and probably have the same performance.
The problem with #1 is that it does't emulate the builtin operator=
which is generally regarded as bad style.
浙公网安备 33010602011771号