\#include "stdafx.h"\
class C{\
public:\
C( int a )\
:\_a(a){}\
int a() const { return \_a; }
int func() const { return \_a; }\
private:\
int \_a;\
};\
\
\
C operator \* ( const C &c1, const C &c2 ){\
return c1.a()\*c2.a();\
}\
int main(){\
C c1(2), c2(2);\
c1\*c2 = c2;
c1.func() = c2.func(); **//
error:对于这种情况,左操作数无法为左值,对于返回的是类类型的时候就不一样了.**\
}
References:
Item 3, Use const whenever possible from <<Effective C++ 3rd>>.