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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -