This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Type of result: const or not
- From: Wei Qin <wqin at EE dot Princeton dot EDU>
- To: gcc-help at gcc dot gnu dot org
- Date: Mon, 4 Aug 2003 11:08:59 -0400 (EDT)
- Subject: Type of result: const or not
Hello,
Scott Meyers recommends in his "50 specific ways ..." book that a
const typed object be returned from an operator. For instance,
const obj operator + (const obj& A, const obj& B);
By doing so, things like below would be banned by the type-checker.
(a+b) = c;
However, the stl with g++ does not return a const type, at least
in the complex and string cases. My questions is: which style is the
better one to follow?
thanks,
Wei