From: Shriramana Sharma <samjnaa@gmail.com>
To: Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: operator! and lvalue
Date: Wed, 27 Jun 2007 09:01:47 +0530 [thread overview]
Message-ID: <4681DA23.7030001@gmail.com> (raw)
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.
next reply other threads:[~2007-06-27 3:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-27 3:31 Shriramana Sharma [this message]
2007-06-28 9:42 ` operator! and lvalue Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4681DA23.7030001@gmail.com \
--to=samjnaa@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).