Type of result: const or not

Wei Qin wqin@EE.Princeton.EDU
Mon Aug 4 15:09:00 GMT 2003


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




More information about the Gcc-help mailing list