Re: reference type methods
On Tue, 15 Jul 2008 06:04:43 -0700, James Kanze wrote:
f(x) = 5; //that can't be done
Of course not. A function expression is an lvalue if and only if its
return type is a reference.
Ah - yes.
That's where I started. This is a definition as I see it, not an implied
affect of references. My text makes it seem like if a function is defined
to return a reference then
simply .....
class f;
class f(int x){
public:
f(){
_x = 10;
}
int& g(int x){
_x = x;
return _x;
}
private:
int _x;
};
f him, her;
her.g(5);
him.g = her.g;
....BECAUSE him.g is an lvalue of type 'refence', as if the order of
operations of the statement would evaluate the left side of the method g
as returning a reference, which would stand in the functions place which
is an lvalue.
It might be an lvalue but if not for some C++ magic syntax behavior, i'd
first expect a type missmatch, as I would if the return type of g() was a
char, or a pointer to array, and then I returned an int. Secondly, I
wouldn't expect the assignment operator to work anyway!
In the case of a the operator[], I thought I might need another operator
overload function called operator[]=
Ruben
--
http://www.mrbrklyn.com - Interesting Stuff
http://www.nylxs.com - Leadership Development in Free Software
So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998
http://fairuse.nylxs.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002
"Yeah - I write Free Software...so SUE ME"
"The tremendous problem we face is that we are becoming sharecroppers to our own cultural heritage -- we need the ability to participate in our own society."
"> I'm an engineer. I choose the best tool for the job, politics be damned.<
You must be a stupid engineer then, because politcs and technology have been attached at the hip since the 1st dynasty in Ancient Egypt. I guess you missed that one."
?? Copyright for the Digital Millennium