"Alex Vinokur" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
[snip]
> Foo(5) is constant
Sorry, Foo(5) is not constant.
Here is an example.
------ foo.cpp ------
#include <iostream>
using namespace std;
struct Foo
{
int var_;
Foo(int var_i) : var_ (var_i) {}
const Foo& operator= (const Foo& that)
{
cout << "BEFORE: var_ = " << var_ << endl;
if (!(&that == this)) var_ = that.var_;
cout << "AFTER: var_ = " << var_ << endl;
return *this;
}
};
int main()
{
Foo(100) = Foo(200);
return 0;
}
---------------------
------ Run ------
$ gpp foo.cpp
$ ./a.exe
BEFORE: var_ = 100
AFTER: var_ = 200
-----------------
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn
=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]