【操作符重载】等号的两种形式

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.

 

来源:http://bytes.com/topic/c/answers/136531-void-operator

posted on 2012-05-24 11:25  LateStop  阅读(2383)  评论(0)    收藏  举报

导航