Article View: comp.std.c++
Article #19return type of operator=
From: Scott Meyers
Date: Sat, 31 Oct 1992 02:52
Date: Sat, 31 Oct 1992 02:52
21 lines
1169 bytes
1169 bytes
Is the return type of operator= an lvalue? In particular, if a, b, and c
are of built-in type, is this legal?
(a = b) = c;
I couldn't find an answer in the ARM, and cfront accepts this, while g++
rejects it.
My goal is to determine the correct type for user-defined operator=. If
the return type is to be an lvalue, then for a class C, the return type
should be C&. However, if the return value is not to be an lvalue, then
op= should return a const C&. Two years ago I thought const C& was the
right type, but since then I've become convinced that C& is better. Now
doubt has surfaced in my mind again, and I'd like to put the matter to
rest.
Scott
-------------------------------------------------------------------------------
What do you say to a convicted felon in Providence? "Hello, Mr. Mayor."
Technical Details
Message-ID:
<1992Oct31.025229.6520@cs.brown.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdmShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!sparky!uunet!brunix!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Subject: return type of operator= Message-ID: <1992Oct31.025229.6520@cs.brown.edu> Sender: news@cs.brown.edu Organization: Brown University Department of Computer Science Date: Sat, 31 Oct 1992 02:52:29 GMT Lines: 21