Bloomberg LP Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




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

I was thinking 'it's POD; nothing', but, with prompting I guessed the 4 - default ctor, copy ctor, operator=, and dtor.

One twist - later I didn't think it'd even compile, after all being a 'class', the default access is private, and the default ctor should be inaccessible to the public right? Well it turns out that the default ctor is an exception to that, even if there're data and members in the class. The rule does come into effect if you write any of your own ctors (default and otherwise). One more piece of C++ trivia.

- JeffD January 29, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

In addition to default ctor, default copy ctor, default copy assignment operator and destructor, non-const address of (&) and const address of operators would also be generated. (I would imagine the interviewer wanted this answer!)

@michael: sizeof(e) = 1, because C++ differentiates between two objects of same kind.

- mag February 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Compiler can create default copy ctor, and default copy assignment operator when they are used. Here, copy ctor and assignment operator are not used. So they are not created yet.

- wsychen November 10, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Everything JeffD mentioned is correct. Also keep in mind that a class Empty {}; differs from a struct EmptyStruct {}; A class generates an entry into the virtual function table (hosted outside of the object). Furthermore, C++ does not allow for allocation of 0 bytes, and sizeof(e) == 1 byte because of this.

- Michael Kofman February 09, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

You were wrong with your first part

- fentoyal February 23, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Nothing is correct. The class without a virtual declaration will not create a vtable. It also does not have any non-private methods, nor any method body. With that said, it is impossible to reference an object of type Empty. The compiler will ignore this class.

- Jurgen.Schober March 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Nothing is correct. The class without a virtual declaration will not create a vtable. It also does not have any non-private methods, nor any method body. With that said, it is impossible to reference an object of type Empty. The compiler will ignore this class.

- Jurgen.Schober March 06, 2012 | Flag


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