From: itaj sherman on 28 Jun 2010 10:29 On Jun 27, 6:27 pm, itaj sherman <itajsher...(a)gmail.com> wrote: > I'm not sure what the standard says about a case like this (mainly per > 12.2/5): > > class B {}; > class D1: public B {}; > class D2: public B {}; > > void foo( bool r ) > { > B const& a = ( r ? D1() : D2() ); //original code doesn't compile, it should have been: B const& a = ( r ? static_cast<B const&>(D1()) : static_cast<B const&>(D2()) ); //or: B const& a = ( r ? B() : D2 ); > // Does the temporary live here? //would that change the answer? > > } > > itaj > itaj -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]
First
|
Prev
|
Pages: 1 2 Prev: You can't trust what the debugger tells you the value is Next: Solid C++ by example |