Bloomberg LP Interview Question
Financial Software DevelopersI don't think, interviewer asked this question to check your understanding on reference......He seems to be concerned with lvalue and rvalue but its make sense to mention about reference after mentioned about lvalue and rvalue........
Legal! The below code works perfectly fine.
int& means return by reference, basically returning the reference to address of a, which is then populated with the value on the right side of =.
int a = 10;
int& function()
{
return a;
}
int _tmain(int argc, _TCHAR* argv[])
{
int x = 5;
function() = x;
return 0;
}
for sure it could be legal.
- Anonymous January 21, 2009===================================
int gg=0;
int& function()
{
return gg;
}
int main()
{
function()=6;
std::cout<<gg<<endl;
return 0;
}