This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]