Bloomberg LP Interview Question for Software Engineer / Developers






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

this will not work. return type is included when comparing the signature. (at least with C++ it is

- NewStart April 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

it will return string

- Vikram Rathode April 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think BabelFish was right. The following code won't compile in VS 2008.

class Base
{
public:
Base() {};
virtual ~Base() {};

virtual int foo() { cout << "base foo" << '\n'; };
};

class Derived : public Base
{
public:
Derived() {};
~Derived() {};

void foo() { cout << "derived foo" << '\n'; };
};

- Anonymous April 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Should be: virtual int foo() { cout << "base foo" << '\n'; return 0; };

Nevertheless it won't compile.

- Anonymous April 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

ur right
error C2555: 'Derived::foo': overriding virtual function return type differs and is not covariant from 'Base::foo'

- hehe April 10, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

You cannot change the return type of virtual function. its an error

- Anonymous April 10, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Exactly. C++ does not allow to change the return type of virtual function, which is to keep the line of polymorphisim.

- peter tang October 09, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Method overriding in wikipedia

- beyondfalcon April 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

in C++, if class B is a subtype of class A, then all member functions of B must return the same or narrower set of types as A

and string is wider than int...

- beyondfalcon April 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Confliciting return type error is thrown by compiler in such situation. nothing like more or less restrictions/

- netappreject May 02, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

you are not allowed to change the return type of the virtual function.You can change argument list though.

- Anonymous June 14, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

new types may not be defined in a return type

- Anonymous September 11, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

will get compilation error.
error: conflicting return type specified for ‘virtual void Derived::foo()’

- jais.ashish October 25, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

overriding doesn't depend upon return type means ,you will return only base or derived class object or ref or pointer

- Anonymous June 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

overriding doesn't depend upon return type means ,you will return only base or derived class object or ref or pointer

- aditya June 28, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

overriding does not depend on return type. it depends on function name and signature.
so it wont be compiler error.

- Napolean March 31, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Napolean is right. Should not have any compiler error. If you want access function in base class from derived instance, you can do

int i = b->Base::function();

- Anonymous April 06, 2010 | 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