Bloomberg LP Interview Question for Financial Software Developers






Comment hidden because of low score. Click to expand.
3
of 3 vote

for sure it could be legal.
===================================
int gg=0;

int& function()
{
return gg;
}

int main()
{
function()=6;
std::cout<<gg<<endl;
return 0;
}

- Anonymous January 21, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

and it will print a 6

- wihenao August 13, 2009 | Flag
Comment hidden because of low score. Click to expand.
-1
of 1 vote

You are wrong.

- Kevin February 06, 2013 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 vote

It can be legal if 'function()' returns a reference to an integer

- haoguohua January 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

And u shud hold the reference somewhere...

- Anonymous January 16, 2009 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

I don't think this could be done in C.References were introduced in C++ only,there were no references(&) in C.

- wolverine October 07, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

illegal ... left side of the assignment operator expected to a variable.

- RK January 13, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is illegal. They are probably looking for a understanding of lvalue and rvalue (in essence what can and cannot appear on the left hand side of an assignment).

- GJ January 14, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I agree with haoguohua

- Aditya January 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I tried to declare function as "int * function" or "int * *function", both don't work..

anyone knows it?

- shoushou January 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

done, I get it:

int & function()
{
int * newint = (int *)malloc(sizeof(int));
return (int &) *newint;
}

this could through g++, and also can print out the number,

- shoushou January 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Read

http://www.parashift.com/c++-faq-lite/references.html

section 8.3

- Anonymous January 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I 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........

- kunalgaind November 15, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

It suffices to give a correct answer. You need not guess the concerns of the interviewer and give an appropriate answer.

- Mahesh February 11, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

int global = 500;

int * function()
{
return &global;
}

int main()
{
*(function())= 1000;
printf("{%d}\n",*function());
getch();
return 0;
}

- It works in C as well :-) November 30, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The above program prints 1000 as expected.

- Anonymous December 01, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

You have changed the problem statement.
The original statement was function()=x. It makes a world of difference by putting the *

- abhimanipal February 22, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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;
}

- satishl November 30, 2011 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More