c++ - Passing reference of parameter's (being itself a reference) target -


i have chained methods that:

purecommand hasher::nametopure(commandname& commandname) {     return this->commandhash.find(commandname).value(); } bytecommand hasher::nametobyte(commandname& commandname) {     return this->puretobyte(this->nametopure(commandname)); } 

the 2nd method passing commandname wrong type 1st method needs reference, not object. i've tried this:

bytecommand hasher::nametobyte(commandname& commandname) {     return this->puretobyte(this->nametopure(*&commandname)); } 

as stated here: how cast/convert pointer reference in c++ - because &commandname gives me pointer... it's passing object again. doing silly way? it's trivial...

there nothing wrong original code. reference can bind object.

(and in fact, no expression ever has reference type. expressions can lvalues, xvalues, or prvalues, , commandname here lvalue, lvalue reference can bind it.)


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -