[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: AW: AW: Binaries for Windows NT
From: |
David Philippi |
Subject: |
Re: AW: AW: Binaries for Windows NT |
Date: |
Fri, 27 Sep 2002 17:15:44 +0200 |
User-agent: |
KMail/1.4.1 |
On Friday 27 September 2002 15:00, Ingo Ruhnke wrote:
> Sure? I don't think so, that would allow things like:
> (a = b) = c;
> Which the normal operator=() for int and floats does not allow.
Did you try? I guess not since his is legal code! I was also astonished but
that's the way the built in operator= works - and the built in behaviour
should be kept whenever possible while overloading operators.
Just try something like:
int foo, bar;
(foo = bar = 7) = 8;
cout << foo << " " << bar << endl;
This will give you "8 7". Probably it's done as a performance improvement.
operator= shall return the new value to allow
foo = bar = baz = value;
and if you just do an assignment the compiler may optimize the return value
away but with a reference as return value this is much less work and thereby
faster to compile I guess. There may also be cases where an unrequired copy
would be made and then thrown away which would be most unfortunate.
C++ is a language you may always learn more about. For example: do you know
what an anonymous union is? I've found it by searching the right page in a
book and got curious. ;-)
Bye David