Bloomberg LP Interview Question for Software Engineer / Developers






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

2 main diff. are
1) References can not be bound to null, where as pointer can be. So that when passing function argument, if passed by reference we do not need to explicitly check if reference is null whereas for pointers it is better to check if it is null. (normally nobody does).
2) No memory is allocated for references, whereas pointer it self is a variable and takes storage space. Reference is an alias.

Although, null reference can be created.
e.g. int *p = 0;
int& r = p;

- Pratik March 23, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

An attempt is being made to bind a reference to an integer to a pointer to an integer... That can't be right. It'll probably fail to compile

- Everyone February 21, 2007 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Then how does the ref know what it referes to?

- Sp March 23, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can not have references to pointer, this is standard C++ rule defined. Program wont compile

- ked February 28, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

int *p = 0;
int& r = *p;

printf ("%d",r);

Here r is a null reference, and the code crashes at printf

- NGK August 06, 2008 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

We can have references to pointer.

int *p = 0;
int *&r = p; //valid. r is reference to pointer to int

Code above is valid. Since p is pointing to null, access to null pointer i.e., either *p or *r will lead to segv

std::cout << r << std::endl; // no probs. prints 0 is null pointer
std::cout << *r << std::endl; // segv
std::cout << *p << std::endl; // segv

- Sudar October 07, 2008 | 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