Bloomberg LP Interview Question for Software Engineer / Developers






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

Apart from that ,
it even has to incremented in the copy constructor.

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

use static!

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

I guess it can be done in the constructor.

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

Have to use a static int counter incremented in constructor and decremented in destructor

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

Define a static int to keep track of the number of objects. Increment it in each of the constructors (be sure to define the default constructor and the copy constructor). Decrement it in the destructor. Also, define a method that returns the static value.

- krkeet February 05, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Using static may not be working in multiple threads situation. Can you come up a better way?

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

Use of static is a good idea. In multiple thread situation, you can write a thread-safe code to update the value of static variable.

- HP March 27, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

An approach that's both easy to implement and that gives the right answer is to create a static counter in Widget, increment the counter each time a Widget constructor is called, and decrement it whenever the Widget destructor is called. You also need a static member function how many to report how many Widgets currently exist. If Widget did nothing but track how many of its type exist, it would look more or less like this:


class Widget {
public:
Widget() { ++count; }
Widget(const Widget&) { ++count; }
~Widget() { --count; }

static size_t howMany()
{ return count; }

private:
static size_t count;
};

// obligatory definition of count. This
// goes in an implementation file
size_t Widget::count = 0;

- anuragpatel.optnio July 25, 2017 | 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