Re: More keyword abomination by C++0x
mytype* operator=(const mytype* Rhs) { ...; return this;}
Would have worked equally as well.
No, it wouldn't. If you defined this operator, then how would you
assign one pointer to another?
[ for an overloaded operator, the same as now - don't think you mean this...
typedef foo* mytype;
mytype* operator=(const mytype* Rhs) { ...; return this;}
]
The compiler would add the implicit '&' and '(*x).' to the type (e.g. a
pointer) for any operator. There would be no problem as the pointers would
be indirectly accessed through a pointer like they are now through a
reference.
It works the same. The fact is C++ doesn't work this way and it never will
but it could have: a what if it was all like '->', arguments too.
Or rather, how do you explain to a newcomer to the language that
mytype* operator=(const mytype* rhs);
is not used when doing this:
mytype *p = new mytype;
Same kind of way as you explain to a newcomer why their += or + operators
don't work properly now because they accidentally added/missed a & now. Or
why -> should return a pointer instead of a reference? Or why you return
'*this' all the time instead of plain 'this' because 'this' is a pointer not
a reference? Or why you are using the "address of" symbol in a function
argument? Or why does my constructor get called repeatedly (passed by value
accidentally in some fn)?
Newbie's questions would just be different. There would be _no_ posts about
const references to temporaries and references as l-values and r-values or
std::swap ;o)
Chris
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]