linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* operator! and lvalue
@ 2007-06-27  3:31 Shriramana Sharma
  2007-06-28  9:42 ` Glynn Clements
  0 siblings, 1 reply; 2+ messages in thread
From: Shriramana Sharma @ 2007-06-27  3:31 UTC (permalink / raw)
  To: Linux C Programming List

In Thinking in C++ chapter on overloading operators, Bruce Eckel gives
the following code:

For a non-member operator:

int operator!(const Integer& a) {
   cout << "!Integer\n";
   return !a.i;
}

For a member operator:

Byte operator!() const {
   cout << "!Byte\n";
   return Byte(!b);
}

My question is: why is there no "const" before Integer and Byte at the
head of the function? There's all that stuff about when temporaries are
returned they are automatically const, but throughout the examples in
this chapter, only operator! is not explicitly specified to have a const
return value whereas in all other relevant cases we have the "const"
specified explicitly.

Shriramana Sharma.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-06-28  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-27  3:31 operator! and lvalue Shriramana Sharma
2007-06-28  9:42 ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).