KyaPoocha.com

Huge Collection of Interview Questions


When are temporary variables created by C++ compiler? 

Provided that function parameter is a “const reference”, compiler generates temporary
variable in following 2 ways.
a) The actual argument is the correct type, but it isn’t Lvalue
double Cuberoot ( const double & num )
{
num = num * num * num;
return num;
}
double temp = 2.0;
double value = cuberoot ( 3.0 + temp ); // argument is a expression and not a Lvalue;

b) The actual argument is of the wrong type, but of a type that can be converted to the
correct type
long temp = 3L;
double value = cuberoot ( temp); // long to double conversion



If you liked this question/asnwer, make sure you
Subscribe to KyaPoocha.com RSS feed!


BOOKMARK THIS : BlinkList | del.icio.us | Digg it | Furl | reddit | StumbleUpon | Yahoo MyWeb |